java - Why does ArrayIndexOutOfBoundsException occur and how to avoid it in Android? -


why arrayindexoutofboundsexception occur , how avoid in android?

this exception thrown when try access array item doesn't exist:

string [] myarray = new string[2];  myarray[2] = "something"; // throws exception myarray[-1] = "something"; // throws exception 

you should check index not negative , not higher array length before accessing array item.


Comments

Popular posts from this blog

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -