// StackTraceDemo.java
public class StackTraceDemo {
public static void main(String[] args)
{
throwAndCatch();
methodA();
throwAndCatch();
} // method main
public static void methodA()
{
throwAndCatch();
methodB();
throwAndCatch();
} // method methodA
public static void methodB()
{
throwAndCatch();
methodC();
throwAndCatch();
} // method methodB
public static void methodC()
{
throwAndCatch();
methodD();
throwAndCatch();
} // method methodC
public static void methodD()
{
throwAndCatch();
} // method methodD
public static void throwAndCatch()
{
try {
throw new RuntimeException(
"Nothing wrong, just a demo.");
} catch ( RuntimeException re ) {
re.printStackTrace();
} // catch
ConsoleInput.pause();
} // method throwAndCatch
} // class StackTraceDemo