public class MyClass {
public static void main(String args[]) {
try {
int arr[] = {4, 7, 0, 1, 5};
System.out.println(arr[9]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("ArrayIndexOutOfBoundsException");
System.out.println("Exception: " + e);
} finally {
System.out.println("finally");
}
}
}
/*
run:
ArrayIndexOutOfBoundsException
Exception: java.lang.ArrayIndexOutOfBoundsException: Index 9 out of bounds for length 5
finally
*/