每当我尝试为父类构造函数调用super时,我都会收到以下错误:
实际和正式的参数列表长度不同
错误发生在超级声明中。
这是我的父类:
public class Person {
protected String name,adress,phone,cell;
protected dateofbirth dob;
@Override
public String toString() {
return "Person{" + "name=" + name + ", adress=" + adress + ", phone=" + phone + ", cell=" + cell + ", dob=" + dob + '}';
}
public Person(String name, String adress, String phone, String cell, dateofbirth dob) {
this.name = name;
this.adress = adress;
this.phone = phone;
this.cell = cell;
this.dob = dob;
}
这是子类:
public class employee extends Person {
private int ID,extension;
private double salary;
public employee(int ID,int extension,double salary,String name,dateofbirth dob,String adress,String phone,String cell){
super(name,adress,phone,cell,dob);
this.ID=ID;
this.extension=extension;
this.salary=salary;
}
@Override
public String toString() {
return "employee{" + "ID=" + ID + ", extension=" + extension + ", salary=" + salary +super.toString()+'}';
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public void setExtension(int extension) {
this.extension = extension;
}
public void setSalary(double salary) {
this.salary = salary;
}
public int getExtension() {
return extension;
}
public double getSalary() {
return salary;
}
}