JavaIt is a case-sensitive language that distinguishes letters. The following describes naming rules for packages, classes, variables, and so on in Java.
Package name: The Package name should be composed of lowercase words, such as net. ebseries. modules.
Class name: The first letter of a Class name is capitalized. Generally, a Class name is composed of multiple words, and the first letter of each word must be capitalized, for example, DataFile or InfoParser.
Variable name: Variable names can be case-insensitive, but the first character must be lowercase. Words are separated by upper-case letters and must contain underscores (_) and dollar signs ($). This character has special meanings for internal classes. For example, inputFileSize.
Interface (Interface): similar to the Class name.
Static FinalVariable (equivalent to constant) Name: Static Final variable names should all be capitalized and indicate the complete meaning, for example: final MAXUPLOADFILESIZE = 1024.
Method name: the first word of the method name should be a verb. The upper and lower cases can be mixed, but the first letter should be lower case. In each method name, uppercase letters separate words and limit the use of underscores. The parameter name must be consistent with the variable naming rules. Use meaningful parameter names. If possible, use the same name as the field to be assigned values:
SetCounter (int size ){
This. size = size;
}
Array Naming: The array should always be named in the following way: byte [] buffer; instead of byte buffer [] (habitual problem ).
It is worth noting that the full English descriptor should be used whenever possible (there are also special cases ). In addition, lowercase letters are generally used, but the class name, interface name, and the first letter of any non-initial word must be capitalized. The following points are summarized as follows: try to use a complete English descriptor, use terminology applicable to relevant fields, use a mix of uppercase and lowercase to make the name readable, and use as few abbreviations as possible, it is wise to use it, unify it throughout the project, avoid using long names (less than 15 letters is a good idea), and avoid using similar names, alternatively, you can only use different names in case and avoid using underscores (except static constants ).