KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > DeeplyNestedAnon


1
2 public class DeeplyNestedAnon {
3
4     public static void main(String JavaDoc [] args){
5         DeeplyNestedAnon d = new DeeplyNestedAnon();
6         d.run();
7     }
8     
9     public void run(){
10     
11         final int x = 8;
12
13         Object JavaDoc o = new TopClass(5) {
14           
15             public int getB(){
16                 
17                 final int y = 9;
18
19                 Object JavaDoc obj = new TopClass(){
20                     public int getB(){
21                         return y;
22                     }
23                 };
24                 return 4;
25                 
26             }
27             public int getC(){
28                 return 6;
29             }
30         };
31
32         o = new TopClass(){
33             public int getB(){
34                 return 7;
35             }
36         };
37     }
38
39    
40 }
41 class TopClass {
42
43     public TopClass(int x){
44     }
45     public TopClass(){
46     }
47     public int getB(){
48         return 2;
49     }
50     public int getC(){
51         return 3;
52     }
53 }
54
55
Popular Tags