Java Chapter Eighth method of Class (i)
First, the method syntax of the class:
Access modifier return value type method name () {
Method body;
}
Ii. specification of method names:
1. Must start with a letter, "_" or "$"
2. You can have numbers, but you cannot start with a number.
3. If the method name is composed of multiple words, the first letter is lowercase,
Capitalize the first letter of the word after it.
4. The method names are verb-based.
Third, the return value of the method
1. There is a return value: You must tell the data type of the return value and return the corresponding value.
Example: Public String getName () {
Return "Zhang San";
}
2. No return value: void
Example: public void Showinfo () {}
Iv. Method of Invocation:
1. Non-homogeneous: Object name. Method Name ();
2. In the same category: Method name ();
Methods can call each other
The position of the variable declaration determines the scope of the method,
A variable declared in a method is called a local variable, and the scope is in the current method.
A variable declared in a class is called a member variable, such as an attribute, and the scope is the entire class.
Six, the package naming specification:
The company's URL is written backwards, followed by the project name, plus the name of the folder to which it belongs.
Com.zhaopin.ts.entity
Com.zhaopin.ts.servlet
Com.zhaopin.ts.dao
Com.zhaopin.ts.dao.imp1
Com.zhaopin.ts.biz
Com.zhaopin.ts.biz.imp1
Vii. Doc NOTES: More information for annotation classes
/** start
*/End
Java Eighth class method (i) Notes