Java Reference
In-Depth Information
Since the loop labeled one does not enclose the break statement, it is not possible to trans-
fer control to that block.
Ask the Expert
Q :
You say that the goto is unstructured and that the break with a label offers a bet-
ter alternative. But really, doesn't breaking to a label, which might be many
lines of code and levels of nesting removed from the break, also destructure
code?
A : The short answer is yes! However, in those cases in which a jarring change in pro-
gram flow is required, breaking to a label still retains some structure. A goto has
none!
Use continue
It is possible to force an early iteration of a loop, bypassing the loop's normal control struc-
ture. This is accomplished using continue . The continue statement forces the next iteration
Search WWH ::




Custom Search