publicclassInvalidArrayAccess {publicstaticvoidmain(String[] args) {String[] students = { "Shreya","Joseph" };System.out.println(students[5]);System.out.println("All seems to be well"); }}
Output:
publicclassInvalidArrayAccess {publicstaticvoidmain(String[] args) {String[] students = { "Shreya","Joseph" };try {System.out.println(students[5]); } catch (ArrayIndexOutOfBoundsException e) {System.out.println("Exception"); }System.out.println("All seems to be well"); }}