日期:2014-05-20  浏览次数:20716 次

怎样在打印语句中打印这3个i变量?
怎样在打印语句中打印这3个i变量?
class x {
int i = 1;
class y {
int i = 2;
void func() {
int i = 3;
System.out.println( ? );
}
}
}


------解决方案--------------------
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);
}
}
}