@@ -0,0 +1,959 @@
+// Use finally.%0Aclass UseFinally %7B%0A  static void genException(int what) %7B%0A    int t;%0A    int nums%5B%5D = new int%5B2%5D;%0A    %0A    System.out.println(%22Receiving %22 + what);%0A    try %7B%0A      switch(what) %7B%0A        case 0:%0A          t = 10 / what; // generate div-by-zero error%0A          break;%0A        case 1:%0A          nums%5B4%5D = 4; // generate array index error.%0A          break;%0A        case 2:%0A          return;%0A      %7D%0A    %7D%0A    catch (ArithmeticException exc) %7B%0A      // catch the exception%0A      System.out.println(%22Can't divide by Zero!%22);%0A      return; // return from catch%0A    %7D%0A    catch (ArrayIndexOutOfBoundsException exc) %7B%0A      // catch the exception%0A      System.out.println(%22No matching element found.%22);%0A    %7D%0A    finally %7B%0A      System.out.println(%22Leaving try.%22);%0A    %7D%0A  %7D%0A%7D%0A%0Aclass FinallyDemo %7B%0A  public static void main(String args%5B%5D) %7B%0A    %0A    for(int i=0; i %3C 3; i++) %7B%0A      UseFinally.genException(i);%0A      System.out.println();%0A    %7D%0A  %7D%0A%7D%0A

Use finally