FileDocCategorySizeDatePackage
StackTrace.javaAPI DocExample944Sat Nov 25 12:54:20 GMT 2000None

StackTrace

public class StackTrace extends Object
Every "Exception" (or subclass) object contains a "stackTrace", or traceback, meant to indicate where the error occurred. Let's find out where a stackTrace comes from, and how to use it, when exceptions are created and thrown. Some textbooks claim that it is the operation of constructing the exception that anchors its trace, others the throwing. Let us see for ourselves.

Fields Summary
IllegalArgumentException
ex
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		StackTrace st = new StackTrace();
		st.makeit();
		System.out.println("CONSTRUCTED BUT NOT THROWN");
		st.ex.printStackTrace();	
		st.throwit();
		// MAY BE NOTREACHED - THINK ABOUT IT!
		System.out.println("CONSTRUCTED BUT NOT THROWN");
		st.ex.printStackTrace();
	
public voidmakeit()

		ex = new IllegalArgumentException("Don't like the weather today");
	
public voidthrowit()

		throw ex;