KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > TryCatchFinallyReturns


1 public class TryCatchFinallyReturns {
2
3     public static void main(String JavaDoc [] args){
4         TryCatchFinallyReturns t = new TryCatchFinallyReturns();
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 JavaDoc e){
21             return 0;
22         }
23         finally {
24             return 3;
25         }
26     }
27 }
28
Popular Tags