1try {
2 array[index] = someValue;
3}
4catch(ArrayIndexOutOfBoundsException exception) {
5 handleTheExceptionSomehow(exception);
6}
1The array index out of bounds error is a special case of the buffer overflow error. It occurs when the index used to address array items exceeds the allowed value. It's the area outside the array bounds which is being addressed, that's why this situation is considered a case of undefined behavior.