-1

I implemented a try catch block.

I tried to implement the catch block in a specific way, but it doesn't work well. If the input isn't an integer, it should repeat and go back to the try block. It works for one time but for more.

Could you give me some help? Thank you

1 Answers1

0

you must do something like:

boolean flag = true;
    while (flag) {
        try {
            // something that may cause the Exception
            flag = false;// done
        } catch (Exception e) {
            e.printStackTrace();
            flag = true;
        }
    }
Mostafa Jamareh
  • 1,389
  • 4
  • 22
  • 54