Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java继承-找不到符号构造函数_Java_Inheritance - Fatal编程技术网

Java继承-找不到符号构造函数

Java继承-找不到符号构造函数,java,inheritance,Java,Inheritance,我不知道如何编译我的子类,即使它调用了超类构造函数 这是一个不会编译的类: package departments; import employees.*; public class DepartmentEmployee extends Employee{ private Department department; public DepartmentEmployee(Profile profile, Address address, Occupation occupati

我不知道如何编译我的子类,即使它调用了超类构造函数

这是一个不会编译的类:

package departments;
import employees.*;

public class DepartmentEmployee extends Employee{

    private Department department;

    public DepartmentEmployee(Profile profile, Address address, Occupation occupation,   Department department) {
        assert (department != null) : "invalid Department";
        super(profile, address, occupation);
        this.department = department;
    }

}
这是超类:

package employees;

public class Employee {

    protected Profile profile;
    protected Address address;
    protected Occupation occupation;

    protected Employee(Profile profile, Address address, Occupation occupation) {
        assert (profile != null) : "invalid Profile";
        assert (address != null) : "invalid Address";
        assert (occupation != null) : "invalid Occupation";
        this.profile = profile;
        this.address = address;
        this.occupation = occupation;
    }

}
子类一直在说“找不到符号-构造函数雇员”。这两个包是不同的。我是否正确链接了它们?

构造函数中的
super()
需要是第一个调用。将其重新排列在
断言
上方

另见:
  • (摘录如下)
调用超类构造函数必须是子类构造函数的第一行


在你的部门员工中,super(…)不应该是ctor中的第一个电话吗?