Java- try catch block not exiting from execution

// Example of  try catch block not exiting from execution


import java.util.*;      //for scanner class

class Test
{

public static void main(String ar[])
{

int a,b,c,i;
a=12;
c=1;
i=1;
Scanner scan=new Scanner(System.in);

while ( i<=10 )
{
try{

System.out.println("Enter value of denominator");
b=scan.nextInt();

c=a/b;

System.out.println("after devide result= "+c);

i++;
}


catch(ArithmeticException e)
{

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

}
}

System.out.println("ok bye!!");


}


}

//output

/*
C:\JAVA>java Test
Enter value of denominator
1
after devide result= 12
Enter value of denominator
2
after devide result= 6
Enter value of denominator
3
after devide result= 4
Enter value of denominator
4
after devide result= 3
Enter value of denominator
5
after devide result= 2
Enter value of denominator//even we enter zero herebut execution does not terminates here
0
please don't devide number by zero
Enter value of denominator
6
after devide result= 2
Enter value of denominator

*/
Reactions: