First, the use of summary---method in Java Learning

Source: Internet
Author: User

2018-08-1017:16:36

Advantages of the method: the use of the method can make the code easy to understand, easy to read, easy to debug the most critical is to greatly reduce the duplication of code, so that the code is reusable:

 public  class   name () { public  static  void   main (string[] arges) { int  n=max (x, y);  public  static  int  Max (int  N, int   m) { return  n+m; }    }                         

The public static is used as the identifier; int belongs to the return value type, Max is the name of the method, and (int n,int m) in Max is the formal parameter, and Max () in the main method is the actual parameter, where the return value type of the Main method is void.

Overloaded methods: overloaded method allows you to define methods of different return value types in the same name, where the formal parameters can be of different numeric types.

 Public Static int max (double n,double  m)publicstaticdouble Max ( double n,double  m)publicstaticdouble max (int x,double y, String z)

method Abstraction: method abstraction is realized through the use of methods and implementation separation, the concept of abstract method can be applied to the development process of the program. can use the ' divide and conquer ' strategy, also known as the gradual refinement, the big problem decomposition into sub-problems, sub-problems can be decomposed into smaller, more easy to deal with the problem.

I. Summary---methods used in Java learning

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.