|
|
|
|
The Throwable Class HierarchyHere's what the exception class hierarchy looks like:
The Throwable ClassThe Throwable class is the superclass of all errors and exceptions in the Java language. Only objects that are instances of this class (or of one of its subclasses) are thrown by the Java Virtual Machine or can be thrown by the Java throw statement. Similarly, only this class or one of its subclasses can be the argument type in a catch clause. A Throwable class instance contains a snapshot of the execution stack of its thread at the time the Throwable was created. It may also contain a message string that gives more information about the error or exception. ErrorsAn Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it. A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method, but not caught, since these errors are abnormal conditions that should never occur. For examples of specific errors, see. ExceptionsThe class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch. RuntimeExceptionsRuntimeException is a subclass of Exception which is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine. A method is not required to declare in its throws clause any subclasses of RuntimeException that might be thrown during the execution of the method, but not caught. Examples of runtime exceptions are:
Checked ExceptionsChecked Exceptions are exceptions that:
The compiler checks that these exceptions are caught or specified by each method, as appropriate. Here's a taste of what part of the Throwable class hierarchy looks like in detail:(Package java.lang)
|
| The page was last updated February 19, 2008 |