怎的在打印语句中打印这3个i变量
怎样在打印语句中打印这3个i变量?
怎样在打印语句中打印这3个i变量?
class x {
int i = 1;
class y {
int i = 2;
void func() {
int i = 3;
System.out.println( ? );
}
}
}
------解决方案--------------------
怎样在打印语句中打印这3个i变量?
class x {
int i = 1;
class y {
int i = 2;
void func() {
int i = 3;
System.out.println( ? );
}
}
}
java, 打印,class,变量,方法
------解决方案--------------------
public class Test {
public static void main(String[] args) {
X xxx = new X();
X.Y y = xxx.new Y();
y.func();
}
}
class X {
int i = 1;
class Y {
int i = 2;
void func() {
int i = 3;
System.out.println(X.this.i);
System.out.println(this.i);
System.out.println(i);
}
}
}