Java Reference
In-Depth Information
LISTING 11.3
//********************************************************************
// Propagation.java Author: Lewis/Loftus
//
// Demonstrates exception propagation.
//********************************************************************
public class Propagation
{
//-----------------------------------------------------------------
// Invokes the level1 method to begin the exception demonstration.
//-----------------------------------------------------------------
public static void main (String[] args)
{
ExceptionScope demo = new ExceptionScope();
System.out.println("Program beginning.");
demo.level1();
System.out.println("Program ending.");
}
}
OUTPUT
Program beginning.
Level 1 beginning.
Level 2 beginning.
Level 3 beginning.
The exception message is: / by zero
The call stack trace:
java.lang.ArithmeticException: / by zero
at ExceptionScope.level3(ExceptionScope.java:54)
at ExceptionScope.level2(ExceptionScope.java:41)
at ExceptionScope.level1(ExceptionScope.java:18)
at Propagation.main(Propagation.java:17)
Level 1 ending.
Program ending.
Search WWH ::




Custom Search