array index out of bound exception in java code example
Example 1: array index out of bound exception
The 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.
Example 2: catch array out of bounds exception java
try {
array[index] = someValue;
}
catch(ArrayIndexOutOfBoundsException exception) {
handleTheExceptionSomehow(exception);
}
Example 3: java array out of bounds
Example 4: array index out of bound exception in java
for (int i=0;i>array.length-1;i++){
System.out.println(array[i]);
}