Goto in Java

So there is no GOTO in java, although I believe it is a reserved keyword.

However, you can do this …


    while ( ... ) {
         level1:
         for ( ... ) {
              for( ... ) {
                   break level1;
              }
         }
    }

It allows you to break out of a set of nested loops back to whichever level you like.

Share