Java: how to access outer class's instance variable by using "this"?
I have a static inner class, in which I want to use the outer class's
instance variable. Currently, I have to use it in this format
"Outerclass.this.instanceVariable", this looks so odd, is there any easier
way to access the instance field of the outer class?
Public class Outer
{
private int x;
private int y;
private static class Inner implements Comparator<Point>
{
int xCoordinate = Outer.this.x; // any easier way to access outer x ?
}
}
No comments:
Post a Comment