class ArrayIndexCheck{ public static void main(String[] args){ int [] x={1, 2, 3, 4}; try{ for (int i=0; i<5; i++){ System.out.println(x[i]); } }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Array index out of bound. "+e.getMessage()); System.out.println("Array index out of bound. "+e); } } }