All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.lang.Throwable
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 contains a snapshot of the
execution stack of its thread at the time it was created. It can
also contain a message string that gives more information about
the error.
Here is one example of catching an exception:
try {
int a[] = new int[2];
a[4];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
Throwable with no detail message.
Throwable with the specified detail
message.
Throwable.
Throwable and its backtrace to the
standard error stream.
Throwable and its backtrace to the
specified print stream.
Throwable and its backtrace to the specified
print writer.
method Throwable() public
Throwable with no detail message.
The stack trace is automatically filled in.
method Throwable(message=String) public
Throwable with the specified detail
message. The stack trace is automatically filled in.
method getMessage() returns String public
Throwable,
or null if this Throwable does not
have a detail message.
method getLocalizedMessage() returns String public
Throwable.
Subclasses may override this method in order to produce a
locale-specific message. For subclasses that do not override this
method, the default implementation returns the same result as
getMessage().
method toString() returns String public
Throwable.
method printStackTrace() public
Throwable and its backtrace to the
standard error stream.
method printStackTrace(s=PrintStream) public
Throwable and its backtrace to the
specified print stream.
method printStackTrace(s=PrintWriter) public
Throwable and its backtrace to the specified
print writer.
method fillInStackTrace() returns Throwable public
try {
a = b / c;
} catch(ArithmeticThrowable e) {
a = Number.MAX_VALUE;
throw e.fillInStackTrace();
}
Throwable object.
All Packages Class Hierarchy This Package Previous Next Index