Jump Statements

In addition to the more common control flow functions, Java also has three kinds of jump statements: break, continue, and return.

The break and continue statements optionally include a label to identify their target statement. A label is any valid identifier prefixed to a statement or block of statements as shown in the following:

myLabelName: statement;

Java does not support a goto operator, but you can use labels to direct execution within nested loops using a break or continue. As you'll see in the next sections, labels are meant to allow you to specify which loop you are referencing with one of these jump statements. They do not, however, give you the ability to jump anywhere in your code like the much maligned goto does. ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.