constructor of subclass in Java
问题 When compiling this program, I get error- class Person { Person(int a) { } } class Employee extends Person { Employee(int b) { } } public class A1{ public static void main(String[] args){ } } Error- Cannot find Constructor Person(). Why defining Person() is necessary? 回答1: When creating an Employee you're creating a Person at the same time. To make sure the Person is properly constructed, the compiler adds an implicit call to super() in the Employee constructor: class Employee extends Person