62,614
社区成员
发帖
与我相关
我的任务
分享
public class Test {
private void show() {
System.out.println("Show");
}
private void print() {
System.out.println("Print");
}
class InnerC {
public void print() {
show(); // 如果不重名,直接调用
Test.this.print(); // 如果重名了,要加上外部函数的名字,加上this
}
}
public void p() {
InnerC c = new InnerC();
c.print();
}
public static void main(String[] args) {
Test t = new Test();
t.p();
}
}
楼主,给你个简单的例子吧,里面调外面,直接调用就行!