Method
Why should there be a way?
* Improve the reusability of code
What is a method?
* Block of code to complete specific functions
Format of the method?
Access modifier return value type method name (parameter type argument name) {
Method code block
return value;
}
Method Format Description:
- Modifier: Public protected private
- Return value: The data type of the result of this function
- Method Name: According to the naming rules, convenient for our call
- Parameters:
- Actual parameters: The parameters that are actually involved in the operation
- Formal parameter: The method definition that is used to accept the actual argument.
- Parameter type: Refers to the data type of the parameter
- Parameter name: Name of variable
- Method Body: The code that completes this function
- Return: The End method
- Return value: The result of the function, brought to the caller by return
Array
Java Basics-Arrays & Methods