continue : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

continue

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:

http://mindprod.com/jgloss/continue.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\continue.html
logo
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.

IP:[65.110.21.43]
Your face IP:[54.205.87.3]
You are visitor number