Java has provided an extensive set of classes to support exception handling in Java. An exception is an instance of a class derived directly, or indirectly, from the Throwable
class. Two predefined Java classes are derived from Throwable
—Error
and Exception
. From the Exception
class is derived a RuntimeException
class. As we will see shortly, programmer-defined exceptions are normally derived from the Exception
class:
There are numerous pre-defined errors that are derived from the Error
and RuntimeException
classes. There is little that a programmer will do with the exceptions derived from the Error
object. These exceptions represent problems with the JVM and normally can't be recovered. The Exception
class is different. The two classes that derive from the Exception
class support two types of exceptions: