Как получить доступ к полю внешнего класса по ссылке на объект внутреннего класса?
class Outer
{
int field;
class Inner
{
void method(Inner parameter)
{
// working on the current instance is easy :)
field = 0;
Outer.this.field = 1;
// working on another instance is hard :(
parameter.field = 2; // does not compile
parameter.Outer.this.field = 3; // does not compile
parameter.outer().field = 4; // This works...
}
// ...but I really don't want to have to write this method!
Outer outer()
{
return Outer.this;
}
}
}
Я также пробовал Outer.parameter.field
и многие другие варианты. Есть ли синтаксис, который делает то, что я хочу?
Float
,Arc2D.Float
,CubicCurve2D.Float
,DataBuffer.Float
и т. д.). - person Ted Hopp   schedule 30.06.2011