Next: Classes and objects
Up: Flow control and loops
Previous: return
Contents
- No goto construct to transfer control to an arbitrary statement in a method.
- Primary uses of goto in other languages:
- Controlling outer loops from within nested loops. Java provides labeled break and continue.
- Skipping the rest of a block of code that is not in a loop when an answer or error is found. Use a labeled break.
- Executing cleanup code before a method or block of code exits. Use a labeled break, or the finally construct of the try statement.
Next: Classes and objects
Up: Flow control and loops
Previous: return
Contents