continue : Java Glossary



Traditional wisdom has it that goto is extremely wicked. goto is a reserved word in Java, but it is also illegal. But you need it in a few situations, e.g. to jump to the end of a loop and to jump out of a loop.

continue jumps to the end of the current loop (for or while) and goes around again. In contrast break jumps just past the end of the current loop.

If you use a name after the continue e.g. continue outer; it will jump to the end of the loop named outer: (Look for the label at the top of the loop). If you use a name after the break e.g. break outer; it will jump just past the end of the loop named outer:.

You can jump out of nested loops, but you cannot jump in.

The equivalent feature in a switch statement is break.

You can also use break to leap out of a loop entirely.

Be careful when using continue or break to make sure There is no intervening loop or switch inside the one you want to leap out of.

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number