1. Concept of inheritance
Inheritance is a relationship between classes and classes, and is a relationship of "is a"
2. Benefits of Inheritance
Subclasses have all the properties and methods of the parent class to implement code reuse
4. Rewriting of Methods (overridding)
If the subclass is not satisfied with the method inherited from the parent class, it is possible to override methods that inherit from the parent class, and when called, the subclass's methods are called first
The return value type, the method name and the parameter type, and the number of arguments are the same as the methods in the parent class, which is called the override of the method
5. Initialization Order of inheritance
1) Initialize the parent class first, and then initialize the child class
2) Initialize the properties in the initialization object before performing the initialization in the constructor method
6.final keywords
Use the final keyword as an identity with a "final" meaning
The final keyword can decorate classes, methods, properties, and variables
Final decorated class, the class is not allowed to be inherited
Final decoration method, the method is not allowed to be overwritten (overridden)
The final decorated property, where the properties of the class are not implicitly initialized (the class's initialization property must have a value) or assigned in the constructor method, only one
Final modified variable, the value of the variable can only be assigned once, which becomes a constant
7.super keywords
Used inside an object, you can represent the parent class object
If the constructor method of the calling parent class is not displayed in the constructor of the subclass, the system defaults to calling the parent class without a parameter construction method
If the constructor method of the child class is displayed in the constructor of the subclass, then super must be in the first row of the child class's construction method
If there are no parameter constructs in the parent class, the constructor method in the subclass implicitly calls the constructor of the parent class, and if there is no parameterless constructor in the parent class, and the subclass does not explicitly call the constructor of the parent class, an error is compiled
Java Notes Collation (v), inheritance in Java