为什么我在雇员构造函数的开始找不到符号 构造函数Person?如何通过子类调用超类的参数化构造函数?
class Person {
String name = "noname";
Person(String nm) {
name = nm;
}
}
class Employee extends Person {
String empID = "0000";
Employee(String eid) {// error
empID = eid;
}
}
public class EmployeeTest {
public static void main(String args[]) {
Employee e1 = new Employee("4321");
System.out.println(e1.empID);
}
}
的'super'关键字是你的朋友。 http://docs.oracle.com/javase/tutorial/java/IandI/super.html – user2336315