Java Override and Overload
Rewrite:
Re-writing refers to the process in which the subclass re-writes the parent class method, as shown in
1: The parameter list cannot be changed.
2: The type of the return value cannot be changed.
3: if the parent class does not throw an exception, a forced exception cannot be thrown when the subclass overrides this method. If the parent class throws an exception, an advanced exception of the parent class exception cannot be thrown when the subclass overrides this method.
4: the access permission of the method after subclass rewriting cannot be lower than that of the method whose parent class is overwritten.
5: Methods declared as final cannot be overwritten.
6: Methods declared as static cannot be overwritten, but can be declared again.
7. The constructor cannot be rewritten.
8: when the child class and parent class are in the same package, the Child class can override all (excluding static and final modifier) Methods of the parent class. When the Child class and parent class are not in the same package, subclass can override the non-final method declared as public and protected for the parent class
Heavy Load
Overload means that in the same type, the method name is the same, the parameter list is different, and the return value type may be different.
1: The parameter list must be changed for the method after the overload.
2: The return type and access modifier can be changed.
3: You can declare or throw more advanced exceptions.
4: You can reload the parent class in the same class or subclass.
5: the return value cannot be used as the standard for definition of heavy loads.