The concept of functions
In order to achieve a particular piece of code function, can be reused
Defined functions
And the main function in parallel, not inside or outside the class method
Function is also called the method
public static void main () {}
None Return Value Static Static modifier method name (parameter list) {
// parameter list: means for receiving an argument, one to one, argument to the parameter, one-way transmission
Call the function name ();
// method body
}
// function syntax
Modifier return type method name (parameter list) {} method thereof
// return a value, the in vivo method, there must return
Composition function
Modifier return type method name (parameter list) {} method thereof
Call functions
Function name (argument list) listing means 0-n parameters
Note: one-way transmission parameter arguments, one to one;
Elementary data type passed as an argument, only a copy of the passed value, the value itself does not move.
Lifecycle functions: call when it is activated, the demise immediately after the function is run.
The return value, the function is complete, the need to give the caller a result.
①return have a return value, the internal method to write the return keyword, type of data to return results and methods consistent with the return value type
② When the method is defined to indicate the type of return value (base, reference, void)