I have a non-working do-while
loop. When I enter a String instead of an int, it should say "bla" and ask again to insert a number, but instead it sends the message text over and over again. What's wrong in this code?
boolean i = true;
do {
i = false;
try {
System.out.println("insert number");
int k = sc.nextInt();
}
catch(InputMismatchException e) {
System.out.println("test");
i = true;
}
} while ( i== true);