I was browsing through some of the base Java objects when I found a section of code surrounded by a scan: {}
block. The following code is from the toLowerCase()
Here, scan:
is simply a label. The break
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.