// StackTraceDemo2.java

public class StackTraceDemo2  {

   public StackTraceDemo2()
   {
      throwAndCatch();
      methodA();
      throwAndCatch();
   }

   public void methodA()
   {
      throwAndCatch();
      methodB();
      throwAndCatch();
   }  // method methodA

   public void methodB()
   {
      throwAndCatch();
      methodC();
      throwAndCatch();
   }  // method methodB

   public void methodC()
   {
      throwAndCatch();
      methodD();
      throwAndCatch();
   }  // method methodC

   public void methodD()
   {
      throwAndCatch();
   }  // method methodD

   public static void main(String[] args)
   {
      StackTraceDemo2 demo = new StackTraceDemo2();
      demo.methodA();
   }  // method main

   public static void throwAndCatch()
   {
      try  {
         throw new RuntimeException(
                 "Nothing wrong, just a demo.");
      } catch  ( RuntimeException re ) {
         re.printStackTrace();
      }  // catch
      ConsoleInput.pause();
   }  // method throwAndCatch
}  // class StackTraceDemo2