且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

类中的 java 构造函数不能应用于给定类型

更新时间:2022-06-11 22:01:27

由于您的超类 Person 没有默认构造函数,因此在您的子类 (StudentStaff),则必须调用超类构造函数作为第一条语句.

Since your super class Person doesn't have a default constructor, in your sub classes (Student and Staff), you must call the super class constructor as the first statement.

你应该像这样定义你的子类构造函数:

You should define your sub class constructors like this:

Student() {
    super("a_string_value", an_int_value);// You have to pass String and int values to super class
}

Staff() {
    super("a_string_value", an_int_value); // You have to pass String and int values to super class
}