Y
YoYoYo
Unregistered / Unconfirmed
GUEST, unregistred user!
有以下代码,请问最后输出什么?看你对java的了解有多深,谁能解释为什么吗?
public class ABC{
int a = 10;
public ABC(){
a = 5;
}
public void print(){
new D();
}
class D extends ABC{
public D(){
ABC.this.a ++;
}
}
public static void main(String[] args){
ABC abc = new ABC();
abc.print();
ABC.D d = abc.new D();
abc.print();
System.out.println("a= " + abc.a);
}
}
public class ABC{
int a = 10;
public ABC(){
a = 5;
}
public void print(){
new D();
}
class D extends ABC{
public D(){
ABC.this.a ++;
}
}
public static void main(String[] args){
ABC abc = new ABC();
abc.print();
ABC.D d = abc.new D();
abc.print();
System.out.println("a= " + abc.a);
}
}