4 Java Nested Try Block Example
4 Java Nested Try Block Example
Content Menu ▼
Syntax:
. ....
. try
. {
. statement 1;
. statement 2;
. try
. {
. statement 1;
. statement 2;
. }
. catch(Exception e)
. {
. }
. }
. catch(Exception e)
. {
. }
. ....
. class Excep6{
. public static void main(String args[]){
http://www.javatpoint.com/nested-try-block 1/2
9/14/2015 Java Nested try block example - javatpoint
. try{
. try{
. System.out.println("going to divide");
. int b =39/0;
. }catch(ArithmeticException e){System.out.println(e);}
.
. try{
. int a[]=new int[5];
. a[5]=4;
. }catch(ArrayIndexOutOfBoundsException e)
{System.out.println(e);}
.
. System.out.println("other statement);
. }catch(Exception e){System.out.println("handeled");}
.
. System.out.println("normal flow..");
. }
. }
← prev next →
http://www.javatpoint.com/nested-try-block 2/2