Classe 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 (ArrayIndexOutOfBoundsException e) {
        System.out.println("exception: " + e.getMessage());
        e.printStackTrace();
    }
	package java.lang;

		(>JDK1.0)public class
	Throwable implements java.io.Serializable {

	    // Constructeurs publics
		(>JDK1.0)    public Throwable();
		(>JDK1.0)    public Throwable(String message);

	    // Méthodes d'instance publiques
		(>JDK1.0)    public native Throwable fillInStackTrace();
		(>JDK1.1)    public String getLocalizedMessage();
		(>JDK1.0)    public String getMessage();
		(>JDK1.0)    public void printStackTrace();
		(>JDK1.0)    public void printStackTrace(java.io.PrintStream s);
		(>JDK1.1)    public void printStackTrace(java.io.PrintWriter s);
		(>JDK1.0)    public String toString();
	}

Christophe Merlet
redfox@redfoxcenter.org
©Tous droits réservés
11 septembre 1998