简体   繁体   English

从内部类中的Local内部类调用方法

[英]Call method from Local inner class in inner class

I have this code: 我有这个代码:

class A{
    class B{
        public void foo(){
            class C{
                public void bar(){
                    baz();
                }
            }
        }
        public void baz(){}
    }
    public void baz(){}
}

If i call baz() in C.bar(), it will call B.baz(). 如果我在C.bar()中调用baz(),它将调用B.baz()。 If i make a reference in A from this, (A aref = this;) then i can call A.baz() through it. 如果我在A中引用A,(A aref = this;)那么我可以通过它调用A.baz()。 Is there any other way to do this? 有没有其他方法可以做到这一点?

You may use A.this.baz() . 你可以使用A.this.baz() A.this is called a qualified this expression . A.this被称为合格的这个表达

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM