Here, scan:
is simply a label. The break <label>
syntax allows one to break out of outer loops, and to simulate some forms of the goto
statement. The syntax is documented in the JLS:
A
break
statement with labelIdentifier
attempts to transfer control to the enclosing labeled statement (ยง14.7) that has the sameIdentifier
as its label; this statement, which is called the break target, then immediately completes normally. In this case, the break target need not be aswitch
,while
,do
, orfor
statement.