Java Learning Note II Java Identifier naming specification

Source: Internet
Author: User
What is an identifier

is when programmers define Java programs, some of the names that are customized. Identifiers can be applied to class names, variables, function names, and package names.

Identifiers must follow the following rules

  1. Identifiers are composed of 26 English character case (a~za~z), Number (0~9), underscore (_), and dollar sign ($).
  2. Cannot start with a number, cannot be a keyword
  3. Strictly case-sensitive
  4. The identifier can be any length
The identifier naming specification in Java is 1. Package Name

All letters lowercase When multiple words are composed (example: Package Com.baidu)

2. class name and interface

Capitalize the first letter of all words when multiple words are composed (example: HelloWorld)

3. variable name and function name

When multiple words are composed, the first letter is lowercase, the other words are capitalized (example: LastAccessTime, GetTime).

4. constant Name

When multiple words are composed, the letters are all capitalized, and multiple words are separated by _ (example: Integer_cache)

Note : Just to increase the normative, readability of a convention, the identifier in the definition of the best to see the name of understanding, improve code reading.

Java Learning Note II Java Identifier naming specification

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.