为什么this语句与super语句不能存在于同一构造函数中?
错误代码:
class Fu
{
Fu( )
{
System.out.println("fu run");
}
Fu(int x)
{
System.out.println("fu:"+x);
}
}
class Zi extends Fu
{
Zi( )
{
System.out.println("zi run");
}
Zi(int x)
{
this( );
super(7); //报错的位置。
System.out.println("zi:"+x);
}
}
class ExtendsDemo
{
public static void main(String[] args)
{
Zi z1=new Zi( );
Zi z2=new Zi(6);
}
} |
|