java.lang
Class Throwable
java.lang.Object
java.lang.Throwable
- Direct Known Subclasses:
- Error, Exception
public class Throwable
- extends Object
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.
Instances of two subclasses, Error
and
Exception
, are conventionally used to indicate
that exceptional situations have occurred. Typically, these instances
are freshly created in the context of the exceptional situation so
as to include relevant information (such as stack trace data).
Here is one example of catching an exception:
try {
int a[] = new int[2];
a[4];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("exception occurred");
}
- Since:
- JDK1.0
- Version:
- 1.44, 02/02/00
- Author:
- unascribed, Helge Böhme
- Available on JControl Devices:
Constructor Summary |
Throwable()
Constructs a new Throwable with null as
its error message string. |
Throwable
public Throwable()
- Constructs a new
Throwable
with null
as
its error message string.