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