Java Eighth class method (i) Notes

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.