是否可以this
从Java内部类中获取对它的引用?
即
class Outer {
void aMethod() {
NewClass newClass = new NewClass() {
void bMethod() {
// How to I get access to "this" (pointing to outer) from here?
}
};
}
}
您可以这样访问外部类的实例:
Outer.this
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句