java编程题 指出下面程序的运行错误,说明原因 20
publicclassOutClass{privateintvarInOuterClass=0;publicOutClass(){}publicvoidcallOutte...
public class OutClass{
private int varInOuterClass = 0;
public OutClass(){
}
public void callOutter(){
int varInOuterMethod = 0;
class InnerClass{
private int varInInnerClass = 0;
public InnerClass(){
}
public void print(){
System.out.println("varInOuterClass" + varInOuterClass);
System.out.println("varInInnerClass" + varInInnerClass);
System.out.println("varInInnerClass" + varInOuterMethod);
}
}
InnerClass inner = new InnerClass();
inner.print();
}
public static void main(String[] args){
OutClass out = new OutClass();
out.callOutter();
}
} 展开
private int varInOuterClass = 0;
public OutClass(){
}
public void callOutter(){
int varInOuterMethod = 0;
class InnerClass{
private int varInInnerClass = 0;
public InnerClass(){
}
public void print(){
System.out.println("varInOuterClass" + varInOuterClass);
System.out.println("varInInnerClass" + varInInnerClass);
System.out.println("varInInnerClass" + varInOuterMethod);
}
}
InnerClass inner = new InnerClass();
inner.print();
}
public static void main(String[] args){
OutClass out = new OutClass();
out.callOutter();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询