当前位置: 代码迷 >> J2SE >> 怎么在打印语句中打印这3个i变量
  详细解决方案

怎么在打印语句中打印这3个i变量

热度:80   发布时间:2016-04-23 20:57:21.0
怎样在打印语句中打印这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);
}
}
}
  相关解决方案