* Overloading of methods (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 differs ② parameter type)
* Supplement: The overloads of the method have no relation to the return value type of the method!
Public classTestoverload {}classoverload{//defines the and of two variables of type int Public intGetsum (intIintj) { returni +J; } //defines the and of three variables of type int Public intGetsum (intIintJintk) { returni + j +K; } //cannot be overloaded with several 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 the and of two double type data Public DoubleGetsum (DoubleD1,DoubleD2) { returnD1 +D2; } //defines the and of three array of type double Public voidGetsum (DoubleD1,DoubleD2,DoubleD3) {System.out.println (D1+ D2 +D3); } //the following two methods form an overload. Public voidMETHOD1 (inti,string str) { } Public voidMethod1 (String str1,intj) { }}
Java Learning--overloading of methods