Java – ArrayIndexOutOfBoundsException

ArrayIndexOutOfBoundsException: Thrown when trying to access an array with an invalid index.
Example:

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

No images available.