Naming usage rules for Java variables

Source: Internet
Author: User

1. Environment variables are usually referred to in the operating system and are used to specify some parameters that the operating system needs to run

2. The variable name begins with a letter, underscore, or dollar sign (¥ above 4), cannot start with a number, is followed by letters, underscores, dollar characters, numbers, variable names are case sensitive, no length limit

Hump Naming method:

1. Variable names should use meaningful English words

2. Variable name if there is only one word, all the letters are lowercase

3. If a variable name consists of multiple English words, capitalize the first letter from the second word

For example:

1. Name the valid variable:

1.Password

2.last_name

3. $abc

4._ref

2. Correct variable naming

1.password

2.lastName

3. BOOL values in Java, only true and false two, not 0 and not 0, or empty and non-null representations, for example, here means the third row error, cannot assign the int variable to the Boolean variable

4.java uses Unicode character codes, which means that the character set of any language in the world can be used in Java, and a char type variable can store a Chinese character, that is, the same storage space used for Chinese characters and English characters.

5. Garbled appearance: Use a character set to convert Chinese characters to code, but the system uses the B character set to convert the encoding into Chinese characters, there will be no code found, garbled

6.

After the source code is changed, it will be recompiled to generate a new class file before executing.

Naming usage rules for Java variables

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.