Compiler Error J0094

Label 'identifier' not found

The compiler detected a label name associated with one of the keywords continue or break, but could not find the label. This error usually occurs when a label does not exist, yet it is being referenced by a break or continue statement. This error can also occur if the label is placed outside the break or continue statement's scope. A break or continue statement must reference a label that precedes an enclosing loop or block. Ensure that the break or continue statement can access a valid label and compile again.

The following example illustrates this error:

public class Simple{
   public int method1(){
      int y;
      for (int x = 0; x < 10; x++){
         y = x *2;
         if (x == 5)
            break test; //error 'test' is not defined as a label
      }
      return y;
   }
}

The following example illustrates the correct usage of a label when used with the break or continue statements:

public class Simple{
   public int method1(int arg1){
      int x,y = 0;
      test: //label precedes the loop.
      if (arg1 = 0)
         return y;
      for (x=1; x < 10; x++){
         y = x * arg1;
         if (y <= arg1){
            y = -1;
            break test;
         }
      }
      return y;
   }
}