The following is the main reference notes organize video tutorial: 2019 version of java-based idea engineer classes + travel project combat , with the book Java core technology perspective, more detailed video, this article is for reference only.
1, overloading:
2, inheritance
Features members inherited method (method of the same name)
3, polymorphism:
Polymorphism is defined:
-> Multi-state members:
Member method of access rules
-> member variable of polymorphism:
Polymorphic benefits:
Transformation and transition up and down the object:
4, overwrite:
-> Case rewritten and overloading:
Overwrite method:
scenes to be used:
Note : the implementation process, try not to modify the old class, to overwrite add new content
Example:
father:
Subclass:
Main method:
Sons class constructor:
Constructor : constructor has no return value, the method name and the class name, its role is for NEW a class, will always first call the constructor of this class, the internal structure of the method can be used for initialization of some variables or in the creation of this Some methods and operations must be called when the class, he is not deliberately method to call, it will automatically create a class as to call
supper Keywords:
Three uses this keyword:
Memory schematic:
5. Inheritance:
Abstract methods:
Abstract class abstract methods:
The parent class is a subclass of the properties and methods have in common extraction, these properties and methods, some have clearly realized, and some can not be determined, then we can be defined as abstract, leaving its subclasses to achieve.
For example, the definition of "animal" parent class, where "Animal name" and "age of the animal" Properties have been identified, but the "animal called" approach is not clear, then you can be "called animal" is defined as an abstract method.
Multiple inheritance:
Attachment: notes, links: https://pan.baidu.com/s/1wg8yO0zZFF2Z8g83gLMoYw
extraction code: 70je
Reproduced in: https: //www.jianshu.com/p/04e98e17df46