有如下java程序,要想在控制台输出10,请补齐代码( ) ----- 单选
class Demo1_InnerClass {
public static void main(String[] args) {
Outer o = new Outer();
o.method();
}
}
class Outer {
public void method() {
//【补齐代码】
class Inner {
public void print() {
System.out.println(num);
}
}
Inner i = new Inner();
i.print();
}
}
A、int num = 10;
B、static int num = 10;
C、num = 10;
D、final int num = 10;
为啥A会报错? |
|