The concept of inheritance
Inheritance is a cornerstone of Java object-oriented programming techniques because it allows the creation of hierarchical classes.
Inheritance means that the subclass inherits the characteristics and behavior of the parent class, so that the subclass object (instance) has the instance domain and methods of the parent class, or the subclass inherits the methods from the parent class, so that the subclass has the same behavior as the parent class.
class inheritance format
In Java, the extends keyword can be used to declare that a class is inherited from another class. The general form is as follows:
class inheritance format
Inherit keyword
Inheritance can use the keywords extends and implements to achieve inheritance and all classes are mostly inherited from java. lang.Object When a class does not inherit two keywords, it inherits object by default (this class is in the java.lang package, so there is no need to import )
final keyword
Don't let its class have subclasses
polymorphism
It is a common method, a common class, and a method with the same name and the same parameter and the same form can constitute polymorphism.