How to access outer outer class(not outer class) property?

for example,if A has inner class B,B has inner class C,all have a property “name”,I know C can access name in B by B.this.name,but how to access name in A from C?

public class A{
    String name="A";
    public class B{
        String name="B";
        public class C{
            String name="C";
            public C(){
                //how to print name in A?
                //System.out.println(B.A.name);
                //System.out.println(B.A.this.name);
                //System.out.println(B.this.A.name);
                //System.out.println(B.this.A.this.name);
            }
        }
        C c=new C();
    }
    B b=new B();
    public static void main(String[] args){
        new A();
    }
}

I tried so many syntex but they cannot compile,also when search java outer class,I found most of them are about outer class only,not outer outer class.


Source: syntax

Leave a Reply