Access outer class from inner class: Why is it done this way?
Posted
by Vuntic
on Stack Overflow
See other posts from Stack Overflow
or by Vuntic
Published on 2010-05-08T06:16:20Z
Indexed on
2010/05/08
6:18 UTC
Read the original article
Hit count: 189
So most of us know how to access an outer class from an inner class. Searches with those words give oodles of answered questions on that topic. But what I want to know is why the syntax is the way it is.
Example:
public class A
{
private class B
{
public void c()
{A.this.d();}
}
public void d()
{System.out.println("You've called d()! Go, you!");}
}
Why is it A.this.d()
? It looks like this
is a static field of class A, but... * am confused *
Forgive me if this is a repeat; like I said, searches with those words give how-answers.
© Stack Overflow or respective owner