Overloading of methods in Java
(1) method overloading is a means of allowing classes to handle different types of data in a uniform manner. Multiple functions with the same name exist at the same time, with different number/types of parameters.
Overloaded overloading is a representation of polymorphism in a class.
(2) Java's method overloading is the ability to create multiple methods in a class that have the same name but have different parameters and different definitions.
The method is called polymorphism by the number of different arguments passed to them and by the type of parameter to determine which method to use.
(3) When overloading, the method name is the same, but the parameter type and number are different, the return value type can be the same or different. The return type cannot be used as a distinguishing criterion for overloaded functions.
Rules for method overloading:
1, must have a different list of parameters;
2, can have a different return type, as long as the parameter list is different can be;
3, can have different access modifiers;
4, can throw different anomalies;
Java Method Overloading Learning notes