|Lesson 7||The try-catch Statement|
|Objective||Describe how Exceptions are caught|
trypart of the statement surrounds the statements for which exceptions are to be caught, and the
catchpart identifies the exception class that is caught and how the exception is to be processed. Multiple
catchclauses may be used. An optional
finallyclause identifies processing that is to be performed whether or not an exception is thrown or caught. Only one
finallyclause may be used.
catchclause declares a variable that identifies the type of exceptions that it catches. The type of this variable may be any class that extends
catchclause catches any exceptions that are subclasses of this type. If multiple
catchclauses are supplied, the first matching
catchclause is executed. Subsequent
catchclauses are ignored.
finallyclause identifies code that is to be executed after the
catchclause (if any) or the
catchstatements may be nested within each other. The nested
catchstatement is contained in the
tryclause of the
catchstatement in which it is nested.
loopexecution, and Exception handling.