ArrayIndexOutOfBoundsException
In short: An array was addressed with an index outside its range.
In more detail: Valid indices are 0 to length−1.
In Depth
Possible causes
- Loop runs to
<=instead of<. - Empty array.
- Wrong index calculation.
Solutions
- Check loop bounds.
- Test the length before access.
- Work with for-each (iterate).