Java – ArrayIndexOutOfBoundsException

ArrayIndexOutOfBoundsException: Thrown when an application tries to access an array with an illegal index.
Example:

int[] arr = {1, 2, 3};
try {
System.out.println(arr[5]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Caught ArrayIndexOutOfBoundsException: " + e.getMessage());
}

No images available.