#A Java method is a code block that can be called repeatedly to implement a specific function.
The definition of a method includes two parts: method header and method body. (Recommended learning: java course )
方法头{ 具体的内容 }
Method header can consist of the method of method, the brackets and parameters after the name and name.
If the method header has parameters:
int but(int a,int b){ return a*b; }
The method header without parameters:
int but() { return 0; }
Method body It consists of a pair of brackets and the content between the brackets. The content includes java statements and variable declarations (referring to local variables).
Such as:
int sum() { int N; for(int n;n<=100;n++) { N=N+n; } return N; }
The above is the detailed content of What is the method in java. For more information, please follow other related articles on the PHP Chinese website!