且构网

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

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

更新时间:2021-08-29 22:12:04

因为你的超级没有'在你的子类( Student Staff )中有一个默认构造函数,你必须调用超类构造函数第一个语句。

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
}