Java program for nested try block

 class NestedTry

{

public static void main(String ar[])

{

try

{

int a[] = {1,2,3,4,5};

System.out.println(a[5]);

try

{

int x = a[2]/0;

}

catch(ArithmeticException e2)

{

System.out.println("Division by zero is not possible");

}

}

catch(ArrayIndexOutOfBoundsException e1)

{

System.out.println("ArrayIndexOutOfBoundsException");

System.out.println("Elements at such indexes does not exists.");

}

}

}



OUTPUT




Comments