1 public class X { 2 3 public static void main(String [] args){ 4 X x = new X(); 5 x.m1(); 6 x.m4(); 7 x.m6(); 8 W w = new W(); 9 w.m9(); 10 } 11 12 public void m1(){ 13 class Y{ 14 public void m2(){ 15 System.out.println("Y 1 m2"); 16 } 17 } 18 Y y = new Y(); 19 y.m2(); 20 class Z{ 21 public void m3(){ 22 System.out.println("Z 1 m3"); 23 } 24 } 25 Z z = new Z(); 26 z.m3(); 27 } 28 29 public void m4(){ 30 class Y{ 31 public void m5(){ 32 System.out.println("Y 2 m5"); 33 } 34 } 35 Y y = new Y(); 36 y.m5(); 37 } 38 39 public void m6(){ 40 new Object (){ 41 public void m7(){ 42 System.out.println("Anon 1 in X m7"); 43 } 44 }.m7(); 45 new Object (){ 46 public void m8(){ 47 System.out.println("Anon 2 in X m8"); 48 } 49 }.m8(); 50 } 51 } 52 class W { 53 54 public void m9(){ 55 new Object (){ 56 public void m10(){ 57 System.out.println("Anon 1 in W m10"); 58 } 59 }.m10(); 60 } 61 } 62 | Popular Tags |