<分区>
如何在不使用辅助变量的情况下调用外部类的回调函数,就像我在下面的示例中所做的那样。
请注意 Calling outer class function from inner class 中描述的解决方案可能行不通。
public abstract class Job {
public void callback();
}
public abstract class ExtendedJob extends Job {
protected void handleResult() {
// workaround for accessing the outter class
final ExtendedJob outter = this;
new ExtendedJob {
public void callback() {
// can i do the same without the outter variable?
outter.callback();
}
}
}
}