Home  >  Article  >  Java  >  What are the naming rules for variables in java

What are the naming rules for variables in java

王林
王林Original
2020-10-19 16:27:1327827browse

The naming rules for variables in Java are: 1. It must start with a letter, underscore, or dollar sign; 2. The variable name must be composed of letters, numbers, and underscores; 3. The variable name cannot conflict with the java keyword .

What are the naming rules for variables in java

Some rules for naming variables:

(Recommended tutorial: java course)

1. It must start with a letter, an underscore, or the dollar sign $;

Variables named starting with the dollar sign$ can be compiled but are not recommended;

Chinese names can also be used as the beginning and The compilation can also pass, but its use is not recommended.

2. Except for the beginning, the following part can be composed of letters, underscores, dollar signs $, and numbers;

3. Although the length of the variable name is not limited, it can express the meaning of the name clearly. Yes;

4. Variable names cannot conflict with java keywords;

5. There is a difference between upper and lower case in renaming, even if it is named by the same word but there are individual letters The difference between upper and lower case results in two different variables.

Related recommendations:Getting started with java

The above is the detailed content of What are the naming rules for variables in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]