Current location - Recipe Complete Network - Dietary recipes - The difference between method overloading and method rewriting in java
The difference between method overloading and method rewriting in java
Method overloading means that in the same class, the declaration parts of two methods, including the name and return value types, are exactly the same, but the number of parameters or parameter types are different. This situation is called method overloading.

Method orverriding refers to a class whose parent class has a method A. He wrote a Method A in this class. The name return value type and parameters are exactly the same, but the method body is different. This is called method rewriting.

In short, method overloading is what happens between two methods with the same name in a class. On the other hand, method rewriting occurs between two methods with the same declaration in the parent class and the subclass.