Java Reference
In-Depth Information
Remember, if no exception is thrown by a try block, no catch statements will be ex-
ecuted and program control resumes after the catch statement. To confirm this, in the pre-
ceding program, change the line
Now, no exception is generated, and the catch block is not executed.
It is important to understand that all code within a try block is monitored for exceptions.
This includes exceptions that might be generated by a method called from within the try
block. An exception thrown by a method called from within a try block can be caught by
the catch statements associated with that try block—assuming, of course, that the method
did not catch the exception itself. For example, this is a valid program:
Search WWH ::




Custom Search