KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > FinallyAndReturnsLJH


1 public class FinallyAndReturnsLJH {
2
3   static String JavaDoc note = "original";
4
5     public static void main(String JavaDoc[] args) {
6         if (m() != "hi")
7           System.out.println("call to m() bad");
8         if (note != "finally")
9           System.out.println("note left from m() bad, note is " + note);
10         if (m1() != "hi1")
11           System.out.println("call to m1() bad");
12         if (note != "trying")
13           System.out.println("note left from m1() bad, note is " +note);
14     }
15
16     public static String JavaDoc m() {
17         try {
18             return "hi";
19         } finally {
20              note = "finally";
21         }
22     }
23
24     public static String JavaDoc m1() {
25         try { note = "trying";
26         } finally {
27             return "hi1";
28         }
29     }
30
31 }
32
Popular Tags