How to fix/prevent the java error java.lang.ArrayIndexOutOfBoundsException and what causes it.
I cant compile my java code, I always get the error message java.lang.ArrayIndexOutOfBoundsException. What am I doing wrong?
You try to access the array with an illegal index, which is the cause of the compiler error. That happens when the index is negative, greater than or equal of the size of the array.
int myArray = new int;
// exception, 777 is greater then 11
int error = myArray;
So in order to avoid this, just take a closer look how you access your arrays.