JAVA learning-method overloading, java-overloading
* Method overload)
* Requirements: 1. In the same Class 2. The method name must be the same 3. The parameter list of the method is different (① the number of parameters is different ② the parameter type is different)
* Supplement: Method Overloading is irrelevant to the return value type of the method!
Public class TestOverload {} class OverLoad {// defines two int variables and public int getSum (int I, int j) {return I + j ;} // defines the sum of the three int variables and the public int getSum (int I, int j, int k) {return I + j + k ;} // cannot be overloaded with other methods // public int getSum1 (int I, int j, int k) {// return I + j + k; //} // public void getSum (int I, int j, int k) {// System. out. println (I + j + k); // defines two double-type data and public double getSum (double d1, double d2 ){ Return d1 + d2;} // defines the three double arrays and public void getSum (double d1, double d2, double d3) {System. out. println (d1 + d2 + d3);} // The following two methods constitute overload. Public void method1 (int I, String str) {} public void method1 (String str1, int j ){}}