|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Throwable
The 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 (IndexOutOfBoundsException e) { System.out.println("exception: " + e.getMessage()); e.printStackTrace(); }
Constructor Summary | |
Throwable()
Constructs a new Throwable with no detail message.
|
|
Throwable(String message)
Constructs a new Throwable with the specified detail
message. |
Method Summary | |
String |
getMessage()
Returns the detail message of this throwable object. |
void |
printStackTrace()
Prints this Throwable and its backtrace to the
standard error stream. |
String |
toString()
Returns a short description of this throwable object. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Throwable()
Throwable
with no detail message.
The stack trace is automatically filled in.
public Throwable(String message)
Throwable
with the specified detail
message. The stack trace is automatically filled in.
message
- the detail message.Method Detail |
public String getMessage()
Throwable
,
or null
if this Throwable
does not
have a detail message.public String toString()
toString
in class Object
Throwable
.public void printStackTrace()
Throwable
and its backtrace to the
standard error stream.
System.err
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |