Escape procedures
Introduction / Definition
Escape procedures transfer control out of a normal execution path. Examples include return, break, continue, and exceptions. They can simplify early termination or exceptional situations. Excessive use can make control flow difficult to understand.
Syntax / Structure / Formula
escape → transfer control to designated point
Detailed Explanation
A search loop may break immediately when the target is found. An exception can escape several nested calls when local handling is inappropriate.
Example
Example: break exits a loop after finding the required item.
Output / Result
Remaining loop iterations are skipped.
Important Points / Notes
- Use escapes purposefully.
- Keep control flow understandable.
Mini Practice Question
Name two escape mechanisms in Java.