Java Reference
In-Depth Information
In the program, both sets of nested loops are the same except for one point. In the first set,
the label precedes the outer for loop. In this case, when the break executes, it transfers
control to the end of the entire for block, skipping the rest of the outer loop's iterations. In
the second set, the label precedes the outer for 's opening curly brace. Thus, when break
stop2 executes, control is transferred to the end of the outer for 's block, causing the next
iteration to occur.
Keep in mind that you cannot break to any label that is not defined for an enclosing
block. For example, the following program is invalid and will not compile:
Search WWH ::




Custom Search