Java Reference
In-Depth Information
The exception mechanism of the Java SE platform is integrated with its synchronization
11.1. The Kinds and Causes of Exceptions
11.1.1. The Kinds of Exceptions
An exception is represented by an instance of the class
Throwable
(a direct subclass of
Object
)
or one of its subclasses.
Throwable
and all its subclasses are, collectively, the
exception classes
.
The classes
Exception
and
Error
are direct subclasses of
Throwable
.
Exception
is the superclass of all the exceptions from which ordinary programs may wish to
recover.
Error
is the superclass of all the exceptions from which ordinary programs are not ordinarily
expected to recover.
Error
and all its subclasses are, collectively, the
error classes
.
The class
Error
is a separate subclass of
Throwable
, distinct from
Exception
in the class
all exceptions from which recovery may be possible without catching errors from
which recovery is typically not possible.
The class
RuntimeException
is a direct subclass of
Exception
.
RuntimeException
is the superclass
of all the exceptions which may be thrown for many reasons during expression evaluation,
but from which recovery may still be possible.
RuntimeException
and all its subclasses are, collectively, the
run-time exception classes
.
The
unchecked exception classes
are the run-time exception classes and the error classes.
The
checked exception classes
are all exception classes other than the unchecked exception
classes. That is, the checked exception classes are all subclasses of
Throwable
other than
RuntimeException
and its subclasses and
Error
and its subclasses.
Programs can use the pre-existing exception classes of the Java SE platform API in
throw
statements, or define additional exception classes as subclasses of
Throwable
or
of any of its subclasses, as appropriate. To take advantage of compile-time checking