Home  >  Article  >  Java  >  what is java identifier

what is java identifier

little bottle
little bottleOriginal
2019-05-21 17:54:4052055browse

In the Java language, the names of variables, constants, functions, and statement blocks are collectively called Java identifiers. Let’s learn more about it with the editor below.

what is java identifier

In the Java language, the names of variables, constants, functions, and statement blocks are all called Java identifiers.

Identifiers are used to name classes, objects, methods, variables, interfaces and custom data types.

Java identifiers consist of numbers, letters, and underscores (_), dollar signs ($), or RMB signs (¥).

is case-sensitive in Java, and it is also required that the first character cannot be a number. Most importantly, Java keywords cannot be treated as Java identifiers.

Naming rules:

1. Class and interface names.

The first letter of each word is capitalized, including upper and lower case. For example, MyClass, HelloWorld, Time, etc.

2. Method name.

The first character is lowercase and the remaining first letters are uppercase. Use underscores as little as possible. For example, myName, setTime, etc. This naming method is called camelCase naming.

3. Constant name.

Constant names of basic data types use all uppercase letters, and words are separated by underscores. Object constants can be mixed. For example, SIZE_NAME.

4. Variable name.

can be written in mixed case, the first character is lowercase, and the first letter of the word separator is capitalized. Don’t use underscores and use dollar signs sparingly. When naming variables, try to make them as clear as possible.

The above is the detailed content of what is java identifier. 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 admin@php.cn