Getting array index out of bounds exception on this

String resultArr[] = response.split("&");
String[] values = resultArr;
String name[] = new String[values.length/2];

for(int i = 0;i<values.length-1;i++)
{
    if(i%2==0)
    {
        name[i] = values[i];
    }
}
Jon Skeet
people
quotationmark

This is the problem:

name[i] = values[i];

Your name array is only half the size of your values array, but you're trying to use the same indexes. I suspect you want:

name[i / 2] = values[i];

Or more readably in my view:

// Note consistency of naming and how the type is specified 
String[] namesAndValues = response.split("&");
if (namesAndValues.length % 2 != 0)
{
    throw new IllegalArgumentException("Uneven name/value pair length");
}
String[] values = new String[namesAndValues.length / 2];
String[] names = new String[values.length];

for (int i = 0; i < values.length; i++)
{
    names[i] = namesAndValues[i * 2];
    values[i] = namesAndValues[i * 2 + 1];
}

people

See more on this question at Stackoverflow