Follow Us
Contribute
  • Register
Errorbase is a collaborative writing project, that aims to build the largest trouble-shooting guide about all kinds of error messages.

Categories

0 votes

This exception is thrown in java when the index is higher than the size of the array. Ex:
int[] arr = {1, 2, 3, 4, 5};
int x = arr[6];

The above example will throw ArrayIndexOutOfBoundsException, because the array contains only 5 integer elements and the index is 6.

requested by (170k points)
edited by

1 Solution

+1 vote

The thrown exception shows the line number in which the problem has occured. The exception thrown for the above example is like this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
at SomePackage.SomeClass.main(SomeClass.java:9)

For this example the problem has occured in line 9. By this way you can reach the variable which created the problem. After finding the variable, debug the code for that variable.

solved by (170k points)
edited by
Nokia browser
...