Method definition:
Modifier return type method name ( parameter type parameter name 1, parameter type parameter name 2, ...) {
The method body
return Return value;
}
Modifiers: fixed write public static
Return Value Type: data type methods need to return the data, if the return does not return a value, the return value type is void
Method name: the name of his own accord to take an identifier naming rules and norms
Method parameters: for receiving incoming data in the method
: Parameter Type Data type Data incoming methods
Parameter name: name taken their own accord identifier naming rules and norms
: The method body code means to be executed
return: key role: a return value back to the caller 2. The end of the method of execution
If the method does not return a value, then no return statement, if necessary, it can only write return;
Return Value: method requires returned data
The method defined steps of:
Clear the return value type
Clear method name
Clear method parameters
The method clear method of body
The return value of a clear method
Parameters: If you need to complete the external method incoming data before they can complete functionality, you will need parameters
Returns: the need to return to the caller after the data if the method is finished, you will need to return value
Parameters defined in the process parameter is the parameter (formal parameter)
Method is invoked arguments passed arguments (actual parameters)
Call the method:
Directly call the method name (actual parameters);
Call type data variable name assignment method name = (actual parameters); data type ----> Return Type
Output calling System.out.println (method name (actual parameters));
note:
No return value method can only be called directly, a method that returns a value can be called directly, call the assignment, output call
Methods Note:
1. A method defined in the class, the outer Method
2. The method does not call will not be executed
3. unrelated to define the order and the order of execution methods, and order-related calls
4. When the definition method, if no return value, the return value of type void
5. If the method does not return a value, you do not need a return statement ,, If necessary, it can only write return;
6.return behind the statement can not write the code
7. If the method does not require parameters, then it empty parentheses ()