I am trying to send the result of a split() function into an array of strings, but I am getting an exception as follows:
java.lang.ArrayIndexOutOfBoundsException: somenumber
I am using the following code, but it returns that exception:
String[] temp;
temp = result.split(" ");
Any suggestions? I want to send the result of the string split() function into an array of strings, and then print the values in a for loop.
I am getting an out of bounds exception in for loop, I use:
for (int i=0;i<=temp.length;i++)
{
out.println(temp[i]);
}
You were declaring a String array as a single string, then declaring a new String in the wrong way.
EDIT: saw you updated your post:
You have to use less then for the condition in the for loop. If an array has 5 elements, the last element will be 4, not 5. The correct code is:
You can even do: