1 public class TryCatchFinallyReturns2 { 2 3 public static void main(String [] args){ 4 TryCatchFinallyReturns2 t = new TryCatchFinallyReturns2(); 5 int y = t.run(3); 6 System.out.println(y); 7 } 8 9 public int run(int i){ 10 int [] x = new int[]{i}; 11 try { 12 if (x[0] == 4) { 13 return 7; 14 } 15 else if (x[1] == 8){ 16 return 2; 17 } 18 19 } 20 catch (ArrayIndexOutOfBoundsException e){ 21 try { 22 if (x[0] == 4){ 23 return 7; 24 } 25 else if (x[1] == 8){ 26 return 2; 27 } 28 } 29 catch (ArrayIndexOutOfBoundsException e1){ 30 return 17; 31 } 32 finally { 33 System.out.println("hello"); 34 return 27; 35 } 36 } 37 finally { 38 System.out.println("Hello 2"); 39 return 28; 40 } 41 } 42 } 43 | Popular Tags |