Labeled continue
Continue an outer loop.
Continuing an Outer Loop
A plain continue only restarts the inner loop. Sometimes you want to skip to the next pass of the outer loop instead.
For that, Java offers a labeled continue.
It pairs a loop label with the continue keyword to control which loop advances.
Labeled continue Syntax
The form is continue label; where the label names an enclosing loop.
Instead of moving the inner loop forward, it jumps to the next iteration of the labeled loop.
Everything left in the inner loop for that round is skipped.
continue outer; // jump to next iteration of 'outer'All lessons in this course
- break and continue
- Labeled break
- Labeled continue
- Avoiding Spaghetti Flow