public class HelloWorld{
String name = "a";
int age = 1;
public class Inner{
String name = "b";
public void show(){
System.out.println("waibu" + HelloWorld.this.name);
System.out.println("neibu" + name);
System.out.println("waibu" + age);
}
}
public static void main (String[] args){
HelloWorld o = new HelloWorld();
Inner i = o.new Ineer();
i.show();
}
}
age也是外部类的成员,需要HelloWorld.this.age调用
Inner i = o.Inner(); 这行打错了
Inner i=o.Inner();
System.out.println("waibu" + HelloWorld.this.name);
改为
System.out.println("waibu" + this.name);
这是什么代码,java吗
Inner i i = o.Inner();