Overload: The method name is the same, but there are multiple functions of the same name with different parameters
Note: 1. Different parameters mean the parameter type, the number of parameters, the order of the parameters at least one different
2. return values and exceptions, and access modifiers, cannot be used as overloaded conditions (because of ambiguity in anonymous invocation, eg:void A () and int A (), if a () is invoked, ambiguity)
The 3.main method can also be overloaded
Overrides: Subclasses override methods of the parent class, requiring the method name to be exactly the same as the parameter type (arguments cannot be subclasses), the return value and the exception are smaller or the same than the parent class (that is, subclasses of the parent class), and the access modifier character parent class is large or the same
Two small and one big
Note: The subclass instance method cannot overwrite the static method of the parent class, nor can the static method of the subclass overwrite the instance method of the parent class (compile-time error), summarized as the method cannot cross overlay
Hiding: A property or method with the same name as a parent class and a subclass has the same property or method of the parent class that is not formally visible
Note: When shadowing occurs, the class is called, and the property or method of the corresponding class is invoked without dynamic binding
Method hides only one form, that is, the same static method exists for the parent class and the subclass
Properties can only be hidden and cannot be overwritten
Subclass instance variable/Static variable can hide instance/static variable of parent class, sum up as variable can be hidden
The difference between hiding and overriding:
A hidden property that accesses a property in the parent class after the subclass is cast to the parent class
The overridden method, when a subclass is coerced into a parent class, calls a method of the subclass itself
Because overlays are dynamic bindings, are constrained by Rtti (run time type identification, run-time type checking), hidden from rtti constraints, summarized as Rtti only for overrides, not for hidden
Special case:
1.final-decorated properties can be hidden, but can not be assigned value, that is, can not use = To assign a value, the net that the final attribute can not be modified, this is not accurate, because for a reference type of variable with final modification, it just can't be pointed to other objects, but it could change its own value, You can use the ArrayList test, the final property can be initialized at run time, but the initialization statement cannot be found
The 2.final decorated method cannot be overridden and can be overloaded
3.final decorated class cannot be inherited
The 4.private method implicitly adds final