Home > Java > javaTutorial > Java Basics Naming of Identifiers

Java Basics Naming of Identifiers

巴扎黑
Release: 2017-06-23 16:36:44
Original
1486 people have browsed it

Naming rules and specifications for java identifiers

First of all, identifiers are places where you can name yourself in a Java program, such as: Class name, method name, interface name, variable name, Constant names...etc.

Naming rules:

1. It consists of 26 English letters in upper and lower case, numbers from 0 to 9, _ or $;

2. It cannot start with a number, that is, it can start with a letter, _ or $;

3. Keywords and reserved words cannot be used as identifiers but can contain keywords or reserved words, for example: static is a keyword, but myStatic can be used as a method name or variable name Although goto is not a keyword, this word has been defined as a reserved word during Java language development (currently not a keyword, However, future version updates may use this word as a reserved word, so it is called a reserved word), but myGoto is a variable name or method name;

##4. The Java language is

strictly case-sensitive, but there is no limit on the length of the identifier;

5. There cannot be spaces in the identifier.

Naming convention:

1. Package name: When defining a package name, all letters must be lowercase, and also lowercase when composed of multiple words;

2 .Class name, interface name: when composed of multiple words, capitalize the first letter of each word, such as: When forming a word, capitalize the first letter of all words except the first word, such as: xxxYyyZzz, and there is no need to capitalize the first letter of a single word;

4. Constant name: all letters are capitalized, composed of multiple words Use underscores to connect, such as: , no error will be reported if you do not comply with it, but for the reusability and readability of the program, it is recommended to abide by the naming convention and develop good writing habits.

The above is the detailed content of Java Basics Naming of Identifiers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template