Java Study Notes day05 and Study Notes day05
1. Method overload
A method with the same name is allowed in the same class, as long as the parameter list of the method is different.
Different parameter lists: different parameter numbers, different parameter types, and different order.
Public class MethodOverLoadDemo {public static void main (String [] args) {} public static void method (int a, int B) {} public static void method (int a, int B, int c) {} public static void method (double a, int B) {} public static void method (int a, double B ){}}
2. Considerations for method Overloading
1. The parameter list must be different.
2. the overload is irrelevant to the parameter variable name.
3. the overload is irrelevant to the return value type.
4. the reload is irrelevant to the modifier.
5. Tip: To reload a method, only view the method name and parameter list.