To a NumberFormatException
object.
Here is a try/catch structure:
try { // statements, some of which might throw an exception } catch ( SomeExceptionType ex ) { // statements to handle this type of exception } .... // perhaps more catch blocks .... // perhaps a finally block
When a catch{}
block receives control (ie. starts execution) it
has a reference to an object of class Exception
(or a subclass of Exception
).
The specific class of the object depends on what exception was thrown.
An exception will be caught if its class or an ancestor class is
in the list of catch{}
blocks.
When an exception event occurs while a program is running,
the Java run time system takes over,
creates an Exception
object to represent the event.
Information about the event is put in the object.
If the exception arose inside a try{}
block,
the Java run time system
sends the Exception
catch{} block
(if there is one).
Exception
objects are actual Java objects.
They
have member data and member methods,
including:
A catch{}
block can use these methods
to write an informative error message to the monitor.