I'm writing a Java Exception Handling program and encountered following issue.
when I enter a invalid input an infinite loop started executing instead of execution start from the try block.
public class Exception_Handling {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
boolean bl=true;
do {
try {
int a = sc.nextInt();
int b = sc.nextInt();
bl=false;
}
catch(InputMismatchException ex) {
System.out.println("Enter Valid Number Format");
System.out.println(ex);
}
}while(bl);
}
}