java naming convention (reproduced)

1. Naming convention

1. The project name is all lowercase

2. The package name is all lowercase

3. Capitalize the first letter of the class name. If the class name consists of multiple words, the first letter of each word must be capitalized.

Such as: public class MyFirstClass{}

4. The first letter of variable name and method name should be lowercase. If the name consists of multiple words, the first letter of each word should be uppercase.

Such as: int index=0;

       public void toString(){}

5. All constant names are capitalized

如:public static final String GAME_COLOR=”RED”;

6. All naming rules must follow the following rules:

1), the name can only be composed of letters, numbers, underscores, $ symbols

2), cannot start with a number

3), the name cannot use the keywords in JAVA.

4), no Chinese and pinyin names are allowed.

 

2. Annotation specification

1. Class annotations

A class annotation must be added in front of each class. The annotation template is as follows:

/**

* Copyright (C), 2006-2010, ChengDu Lovo info. Co., Ltd.

* FileName: Test.java

* Detailed description of the class

*

* @author class creator name
    * @Date Date created

* @version 1.00

*/

 

2. Attribute annotation

A property annotation must be added before each property. The annotation template is as follows:

/** prompt message */

private String strMsg = null;

 

3. Method Notes

A method annotation must be added before each method. The annotation template is as follows:

/**

* Detailed instructions for the use of class methods

*

* @param parameter 1 Instructions for parameter 1

* @return the description of the returned result

* @throws the exception type. The error code indicates the description of throwing exceptions from such methods

*/

4. Constructor comments

An annotation must be added before each constructor. The annotation template is as follows:

/**

* Detailed instructions for the construction method

*

* @param parameter 1 Instructions for parameter 1

* @throws the exception type. The error code indicates the description of throwing exceptions from such methods

*/

 

5, method internal annotation

Use single-line or multi-line comments inside the method, which are added according to the actual situation.

For example: //background color

       Color bgColor = Color.RED

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324809236&siteId=291194637