public class BasicTryCatch {
public static void main(String[] args) {
int[] array = new int[3];
try {
array[4] = 1; // outside its boundry
} catch (Exception e) {
System.out.println("Exception thrown: " + e.toString());
}
}
}
Output:
$ java BasicTryCatch Exception thrown: java.lang.ArrayIndexOutOfBoundsException: 4