February 2014
Beginner
1248 pages
62h 25m
English
When lines 21–26 catch the exception, the program displays a message indicating the problem that occurred. Line 23 implicitly calls the exception object’s toString method to get the error message that’s implicitly stored in the exception object and display it. Once the message is displayed in this example, the exception is considered handled and the program continues with the next statement after the catch block’s closing brace. In this example, the end of the for statement is reached (line 27), so the program continues with the increment of the control variable in line 15. We discuss exception handling again in Chapter 8, and more deeply in Chapter 11.
Read now
Unlock full access