JavaSE review Diary: method call and method overloading

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.