Relevant SectionsRead Section 5.2 "Selection Statements" and all sections from 5.5 "Stack-based Execution and Exception Propagation" to the end of the chapter. Study NotesThe if statement affects control flow based on a boolean expression. The switch statement affects control flow based on a non- long integral expression. The break statement exits the loop or switch statement. There are three basic control flow scenarios that may occur in conjunction with exceptions. The control flow for each of these scenarios should be understood :
The finally block is always executed. The boolean expression of an assert statement will be evaluated if assertions are enabled during runtime, and an java.lang.AssertionError will be thrown if the result is false. An augmented form of the assert statement allows a value to be displayed as a detailed error message. AssertionError is a direct subclass of Error . The assertion mechanism should be used to write correct programs, and the exception facility should be used to make them robust. |