Java Naming rules
Hump rule:
All letters are in lowercase (including abbreviations) and the first letter of the word is in uppercase.
The first letter of each word is capitalized to get a big camper name.
Except for the first word, the first letter of each word is capitalized to get a (small) camper name.
In order to avoid ambiguity, the small and medium-sized hump method is called the hump method, and the large hump/Pascal method is called the big hump law.
1. Package
Project package naming rules: <domain name reversal>. <team name>. <Project Name>. For related projects, you can use the naming rules of <domain name reversal>. <team name>. <Parent Project Name>. <sub-project name>.
The name must contain lowercase English letters, and cannot contain underscores. (Except constants, underlines and other characters are not recommended in Java Naming Conventions)
Example:
com.cnblogs.niceboat.soyteam.anticorruptionsystem
2. Class/Object, Interface
Classes and interfaces use the big camper Method
Abstract classes start with "Abstract ".
The Exception class name uses "Exception" as the end of the class name
The Test class uses "Test" as the end of the class name
In interface-oriented programming, the naming rules for interface implementation classes are: <Interface Name> + "Impl ". The Hungarian naming method is forbidden.
Example (correct ):
Interface |
Implementation class |
HandsomeProvider |
HandsomeProviderImpl |
Hungarian naming method (not recommended ):
Interface |
Implementation class |
IHandsomeProvider |
HandsomeProvider |
3. Method/Function
The method is named by the camper method. Generally, a verb or verb + noun combination is used.
Set/obtain a value method, named setV/getV
Return length method, named length
Method for Determining boolean values, named isV
To convert an object to a specific type, you should name it toT.
Example:
GetSecretStage () |
Length () |
IsEmpty () |
ToSpecialFormat () |
4. Variable
Variable naming uses the hump method
Example:
OpenId
The name of changliang is separated by uppercase letters and underscores (_).
Example:
MAX_SUITABLE_SIZE
For more information about the naming rules of the hump rule (especially the abbreviations), see the following table:
Original |
Camper Method |
Big hump method |
Not recommended |
Xml http request |
XmlHttpRequest |
XmlHttpRequest |
XMLHTTPRequest |
New customer ID |
NewCustomerId |
NewCustomerId |
NewCustomerID |
Inner stopwatch |
InnerStopwatch |
InnerStopwatch |
InnerStopWatch |
Support IPv6 on iOS |
SupportIpv6OnIos |
SupportIpv6OnIos |
SupportIPv6OniOS |
Anglo-Saxon England |
AngloSaxonEngland |
AngloSaxonEngland |
Anglo-SaxonEngland |