Advertisement
jaVer404

ExceptionExampleOriginal

Apr 26th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. class ExceptionExampleOriginal
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         System.out.println("main begin");
  6.         try
  7.         {
  8.             System.out.println("main before call");
  9.             method1();
  10.             System.out.println("main after call");
  11.         }
  12.         catch (RuntimeException e)
  13.         {
  14.             String s = e.getMessage();
  15.             System.out.println(s);
  16.         }
  17.         System.out.println("main end");
  18.     }
  19.    
  20.     public static void method1()
  21.     {
  22.         System.out.println("method1 begin");
  23.         method2();
  24.        
  25.         System.out.println("method1 end");
  26.     }
  27.    
  28.     public static void method2()
  29.     {
  30.         System.out.println("method2");
  31.         String s = "Message: Unknown Exception";
  32.         throw new RuntimeException(s);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement