this 与 super 反复问题?
我们都知道 this 和 super keyword,在 调用 构函数的时候,
都必须写在第一行中。
this 调用的是当前的类的构造函数。
super 调用的是父类的构造函数!
this和super可不能够反复??
class Student extends Person
{
int grade;
Student()
{
super();
System.out.println("我的是Student 的无参构造函数! ");
}
Student(String name,int grade)
{
this();
super(name);
this.grade = grade;
}
}出错:
Constructor call must be the first statement in a constructor

浙公网安备 33010602011771号