1. Differences between method overloading and method Rewriting
| Differences |
Method overload |
Method Rewriting |
| English Words |
Overloading |
Override |
| Concept |
The method name is the same, and the number or type of parameters are different. |
The method name is the same, the number and type of parameters are the same, and the access permission of the method cannot be stricter. |
| Scope of use |
Occurs in the same class |
Occurs in the inheritance relationship and is rewritten by the subclass. |
2. Comparison between super and this
| Comparison |
Super |
This |
| Scope of use |
Is the content of the parent class accessed by subclass |
Is to directly access the content in this class |
| Access attribute format |
Super. parent class attribute. If the attribute is not rewritten, you can also leave super |
This. attributes of this class |
| Access Method format |
Super. parent class method (). If the parent class method is not rewritten, you can call the method in the parent class without writing super. |
This. This class method () can be used to call the method of this class without writing this. |
| Format when accessing the constructor |
Super () is the constructor used to access the parent class and must be placed in the first line. |
This () is to access other constructor methods in this class (note that this is the entry !), Must be placed in the first line |
| Special Points |
None |
This indicates the current object. The object of the current operation method is the current object. |