继承类的含参构造函数注意事项
继承类的含参构造函数注意事项
父类
public class Person {
public Person(int a){
System.out.println("Person但构造器");
}
}
子类
public class Student extends Person{
public Student(int a){//编译不通过,Person中没有默认的构造函数,隐式super()调用失败,可以显示写super(a);
System.out.println("Student单构造");
}
}

浙公网安备 33010602011771号