< Previous | Contents | Next >

Using break and continue Statements

Its possible to alter the behavior youve seen in loops. You can immediately exit a loop with the break statement, and you can jump directly to the top of a loop with a continue statement. Although you should use these powers sparingly, they do come in handy sometimes.


 

Introducing the Finicky Counter ProgramCreating a while (true) LoopUsing the break Statement to Exit a LoopUsing the continue Statement to Jump Back to the Top of a LoopUnderstanding When to Use break and continue