Java naming specification

  • 2020-05-30 20:16:40
  • OfStack

Code purpose: to achieve standardization in the coding process, for the later development of the program to develop good habits.

1. All project names are in lowercase

2. All package names are in lowercase

3. Capitalize the first letter of the class name. If the class name consists of more than one word, capitalize the first letter of each word.

E.g. public class MyFirstClass{}

4, variable names, method names start with lowercase letters, if the name is composed of more than one word, the first letter of each word should be capitalized. (hump)

Such as: int index = 0;

public void toString(){}

5. All constant names are capitalized

For example: public static final String GAME_COLOR= "RED";

6. All naming rules must follow the following rules:

Names can only be made up of letters, Numbers, underscores, and $signs You can't start with a number The name cannot use the keyword in JAVA. Do not allow the Chinese and pinyin name.

7. Maven naming specification

GroupId and ArtifectId are all lowercase, multiple words are separated by -, and no hump is used

Related articles: