1 import java.util.*; 2 3 public class InnerAccessLJH { 4 public static void main(String [] args) { 5 if (new C().getCount() == 3) 6 System.out.println("correct"); 7 else 8 System.out.println("incorrect"); 9 } 10 } 11 12 13 class C { 14 protected int i = 2; 15 private String s = "hi"; 16 17 Runnable r = new Runnable () { 18 public void run() { 19 s += "s"; 20 } 22 }; 23 24 public int getCount() { 25 return new Object () { 26 public int m() { 27 r.run(); 28 return s.length(); 29 } 30 }.m(); 31 } 32 } 33 34 class DI extends D.Inner { 35 } 36 37 38 class D implements Map.Entry { 39 public Object getKey() { return null; } 40 public Object getValue() { return null; } 41 public Object setValue(Object o) { return o; } 42 43 static class Inner {} 44 } 45 46 47 class Outer { 48 class Middle { 49 class Inner { 50 void m() { 51 Inner.this.m1(); 52 Middle.this.m1(); 53 Outer.this.m1(); 54 } 55 56 void m1() {} 57 } 58 void m1() {} 59 } 60 void m1() {} 61 } 62 63 | Popular Tags |