我已经在Java中实现了嵌套类,并且需要从内部类调用外部类方法。
class Outer {
void show() {
System.out.println("outter show");
}
class Inner{
void show() {
System.out.println("inner show");
}
}
}
如何调用该Outer
方法show
?
您需要通过外部类为调用添加前缀:
Outer.this.show();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句