1 public class ExceptionTest { 2 3 public int testCatch() { 4 try { 5 throw new MyException(); 6 } catch (MyException exc) { 7 return 1; 8 } 9 } 10 11 public int testFinally(int x) { 12 try { 13 if (x == 0) { 14 throw new MyException(); 15 } else if (x == 1) { 16 throw new MyOtherException(); 17 } 18 } catch (MyException exc) { 19 x = 3; 20 } catch (MyOtherException exc) { 21 x = 2; 22 } finally { 23 x = 1; 24 } 25 return x; 26 } 27 } 28 29 class MyException extends java.lang.Exception { 30 } 31 32 class MyOtherException extends java.lang.Exception { 33 } 34 35 // vim: tabstop=4 expandtab shiftwidth=4