Java Naming Convention
Java Naming Convention
1、 Naming conventions
2. Package name all lowercase
3. The first letter of the class name is capitalized. If the class name is composed of multiple words, the first letter of each word should be capitalized.
For example: public class myfirstclass {}
For example: int index = 0;
public void toString(){}
5. Constant names are all uppercase
For example: 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 and $symbols
2) , cannot start with a number
3) , names cannot use keywords in Java.
4) . Chinese and Pinyin naming are not allowed.
2、 Annotation specification
1. Class annotation
Class comments must be added in front of each class. The comment template is as follows:
/**
* Copyright (C),2006-2010,ChengDu Lovo info. Co.,Ltd.
* FileName: Test. java
*Detailed description of class
*
*@ author class creator name * @ date creation date
* @version 1.00
*/
2. Attribute annotation
Attribute comments must be added before each attribute. The comment template is as follows:
/**Prompt information*/
private String strMsg = null;
3. Method notes
Each method must be preceded by a method note. The note template is as follows:
/**
*Detailed instructions for using class methods
*
*Usage description of @ param parameter 1
*@ return description of the returned result
*@ throws exception type The error code indicates the description of the exception thrown from this method
*/
4. Construction method notes
Each construction method must be preceded by a note. The note template is as follows:
/**
*Detailed instructions for the construction method
*
*Usage description of @ param parameter 1
*@ throws exception type The error code indicates the description of the exception thrown from this method
*/
5. Method internal comments
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