Compiler Error J0018

Expected 'while'

The compiler expected to find the keyword while in the position indicated by the error message. This error usually occurs when a do/while loop is not syntactically correct.

The following error illustrates this error:

public class Simple{
   public void method1(){
      do{
          // do something useful here
      }; //error: missing 'while' statement
}

The following code illustrates the correct form of a do/while loop:

public class Simple{
   public static void method1(){
      int x = 10;
      do{
        System.out.println(x);
        x--;
      }while(x != 0); //this is correct form for do/while loop
   }
   public static void main(String args[]){Simple.method1();}
}