Java- Example of Nested Try

//Example of Nested Try
class Test{

public static void main(String ar[]){
try{//Outer Try
int a=Integer.parseInt(ar[0]);
int b=Integer.parseInt(ar[1]);
try{//inner try
int c=a/b;
System.out.println("c="+c);
}catch(ArrayIndexOutOfBoundsException f){
System.out.println("provide two parameters");

}
}catch(ArithmeticException e){

System.out.println("Don't divide number by zero");

}
}
}

Reactions: