What is java method (Method)?

A method is a set of code blocks in order to achieve a specific set of functions. The method in semantic mainly in the following two:
①: structured code
code is organized by function, the structure of the code is relatively clear, easy to read and modify, maintainability program is strong.
②: reduce code duplication
a fixed function, may be used more than once in the program, when only need to call method written without repeatedly writing the corresponding function code.

 

Methods in writing to note the following two points:
①: rigorous logic
a way to achieve full functionality, so in writing to take into account all possible circumstances, and in each case to make appropriate treatment.
②: versatility (reusable)
method implemented is a feature in the actual implementation, as needed, the methods have a certain versatility , unless absolutely necessary, do not write specific method. In the Java language, proper use, will make the program more elegant, easy to read and use.

 

My summary:

Method: code segment reusable;

Complete set of independent functions of the program piece of code.

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11130886.html