Java Question

Whats wrong with my code? Do while and Try Catch

Keep getting syntax error, insert while expression to complete do statement. It maybe something simple like curly brackets etc.

{
int num = 0;
//flag
boolean inputOk = false;
Scanner s = new Scanner (System.in);

do {
try {
System.out.println("Enter a number....");
num =s.nextInt();

System.out.println("you entered : " + num);
// got here then things are good
inputOk = true;

} catch (InputMismatchException ex) {
System.out.println("Again please....digits only");
// flush the scanner
s.next();
}

} while (inputOk != true);
s.close();
System.out.println("Thank you");
}

Answer

You are missing ending curly brackets "{" of Do I have corrected it in below code

     int num = 0;
    //flag
    boolean inputOk = false;
    Scanner s = new Scanner (System.in);

      do {

        try {
            System.out.println("Enter a number....");
            num =s.nextInt();

        System.out.println("you entered : " + num);
        // got here then things are good
        inputOk = true;

        } catch (InputMismatchException ex) {
            System.out.println("Again please....digits only");
            // flush the scanner
            s.next();


        }} while (inputOk != true);
        {
           s.close();
           System.out.println("Thank you");
        }