Java Naming Convention

Source: Internet
Author: User

1. Package
All letters are in lowercase. Hierarchy, separated by periods. Com. Sun. medialib com. Sun. jdi. Event

2. Classes and interfaces
The first letter of each word is capitalized. Using a noun or noun phrase, the timer bufferedwriter interface can also be named by an adjective ending with "-able" or "-visible. Runnable accessible

3. Methods, Domains
The first word is in lowercase, and the first letter of each word is in uppercase.
The method for executing an action is usually named by a verb or verb phrase. Append drawimage
For a Boolean method, its name often starts with the word "is", followed by a noun or noun phrase, or any word or phrase with an adjective function. Isdigit isprobableprime isempty isenable
If the method returns a non-Boolean function or attribute of the called object, a noun, noun phrase, or verb phrase starting with the verb "get" is often used to name it. Size hashcode gettime
If the class of a method is a bean, the format starting with "get" is mandatory.
The method for converting object types and returning a different type of independent object is usually called totype. Tostring toarray
The method for returning a view is usually called astype. Aslist
Return a primitive type method that is the same as the value of the called object. It is usually called typevalue. Intvalue
The common static factory names are valueof and getinstance.

4. Constants
Each letter is in uppercase and separated by an underscore. Values negative_infinity

5. Local Variables
The first word is in lowercase, and the first letter of each word is in uppercase. Abbreviations are allowed. The meaning of a single character or short Character Sequence depends on the context where the local variable is located. I xref housenumber

 

 

Related Article

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.