: This article mainly introduces the JavaSE review Diary: Method calling and method overloading. For more information about PHP tutorials, see.
/** Method call and method overload * // ** What is a method? * A method is a code segment with a name. * call a method: * call another method; * You can also think that "the name of another method ()" is the call of the method. * Method overloading: * multiple methods with the same name are written out of the main method, however, when calling this method in the main method, the program will call the method that matches the parameters in the call method by default; * /// method form and method class Call/* public class JavaSE {public static void main (String [] args) {JavaSE. method_1 (); // method call is: class name. method name (real parameter list); Method_2 (); // The static method in the class called by the main method can also be written like this; Method_3 ();} public static void Method_1 () {System. out. println ("I'm handsome");} public static void Method_2 (int a, int B) {int c = a + B; System. out. println (c);} public static int Method_3 (int e, int d) {// note that static follows int, which is the return value type, this is the final return statement of the method; int f = e + d; System. out. println (f); return f; // The return statement must return values when the return value type is available; otherwise, an error is returned ;}} * /// override // method's heavy-duty publicclass JavaSE {publicstaticvoid main (String [] args) {Method_4 (1, 1.0); // here 1 is int type, 1.0 is double type, and the result is 2.0. The result is automatically converted to double type Java. sum (); // The method used to call the external class must be the external class name. method name (real parameter list);} publicstaticvoid Method_4 (int a, int B) {int c = a + B;} publicstaticvoid Method_4 (int a, double B) {System. out. println (a + B) ;}} class Java {publicstaticvoid sum (int a, int B) {System. out. println (a + B);} publicstaticvoid sum (int a, double B) {System. out. println (a-B );}}
The above introduces the JavaSE review Diary: Method calling and method overloading, including some content, hope to be helpful to friends who are interested in PHP tutorials.