Omn*_*ent 2 java inner-classes method-invocation
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何打印消息bMethod
吗?
小智 6
您只能实例MethodLocalInner
中aMethod
.那样做
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
}
}
MethodLocalInner foo = new MethodLocalInner(); // Default Constructor
foo.bMethod();
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4648 次 |
最近记录: |