gberes
gberes

Reputation: 1169

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(). If i make a reference in A from this, (A aref = this;) then i can call A.baz() through it. Is there any other way to do this?

Upvotes: 3

Views: 244

Answers (1)

Ben Schulz
Ben Schulz

Reputation: 6181

You may use A.this.baz(). A.this is called a qualified this expression.

Upvotes: 8

Related Questions