class Fu
{
int num = 8;
{
System.out.println("fu");
}
public Fu(){
super();
show();
}
public void show(){
System.out.println("fu show"+num);
}
}
class Zi extends Fu
{
int num = 10;
{
System.out.println("zi");
}
public Zi(){
super();
show();
}
public void show(){
System.out.println("zi show"+num);
}
}
class ExtendsDemo5
{
public static void main(String[] args){
new Zi();
}
}
输出结果是
fu
zi show0
zi
zi show 10
我没明白zi show0是为什么,为什么不是10?或者8?
|
|