Java Naming conventions

Source: Internet
Author: User

Class name

  The class name should be a noun, describing the object. Should follow the camel style , that is, only the first letter of each word capitalized.

Interface Name

  The interface name should be an adjective, describing the function. should be "Able", "ible" end, otherwise it should be a noun. Usually follows the same size convention as the class name.

 Public Interface Serializable {...}  Public Interface Systempanel {...}

Method name

The method name should contain a verb. Write in uppercase and lowercase letters, beginning with a lower-case letter, and capitalized with the first letter of each word. The method name can also contain adjectives and nouns.

instance and static variable names

Instance variables should be nouns and should follow the same casing conventions as the method names .

 Public String Waypoint;

parameter and local variable name

A single word, acronym, or abbreviation that should be a descriptive lowercase letter. If you need more than one word, you should follow the same casing convention as the method name.

The temporary variable name may be a single letter, such as a i,,j. The character variable c,d.

Generic type parameter name

The name of the generic type parameter should be a single letter in uppercase, suggesting T.

The collection framework uses generics extensively. E represents the collection element,S represents the service loader, and K and V represent the keys and values for the mapping.

Constant name

Constant names apply all large letters, and multiple words should be separated by underscores .

Enumeration name

The conventions for enumerating names and class names are the same. The enumeration collection of objects (selections) should all use uppercase letters.

Package Name

The package name should be unique and consist of lowercase letters. You can use underscores if you want.

 Package Com.zhaoyu1995.fish_finder;

Public packages should be written in the order of the organization's Internet domain name, with the top-level domain name of a single word, followed by the organization, project, or department name (the inner package is usually named after the project).

Package names beginning with Java and javax are restricted and can only be used to provide a compliant implementation for the Java class library.

Acronyms

When an acronym is used in a name, the first letter of the initials should be capitalized when it is appropriate to use capital letters.

 Public String getgpsversion () {...}

Java Naming conventions

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.