Current location - Education and Training Encyclopedia - Educational Knowledge - When java constructs a method, why must there be a parameterless constructor?
When java constructs a method, why must there be a parameterless constructor?
When 1. subclasses inherit the parent class, they will automatically inherit the default constructor of the parent class (that is, inherit the constructor without parameters).

2. The parameterless constructor is the parent class of all the constituent functions. If the default parameterless constructor is not written, subclasses will report an error when inheriting, because the system does not know which constructor to inherit, and must explicitly use the super () keyword to describe it. So in order to avoid this mistake, a constructor without parameters will be written in a class with multiple constructors.

Self-education and co-education are expected to be adopted.