Package names
- Package names should be all lower case without underscores or other special characters.
- Package names begin with the reversed authority part of the web address of the company of the developer. This part can be followed a by project/program structure dependent package substructure.
- Don’t use plural form. Follow the convention of the standard API which uses for instance
java.lang.annotation
and not java.lang.annotations
.
- Examples:
com.yourcompany.widget.button
, com.yourcompany.core.api
Class, Interface and Enum Names
- Class and enum names should typically be nouns.
- Interface names should typically be nouns or adjectives ending with …able.
- Use mixed case with the first letter in each word in upper case (i.e. CamelCase).
- Match the regular expression
^[A-Z][a-zA-Z0-9]*$
.
- Use whole words and avoid using abbreviations unless the abbreviation is more widely used than the long form.
- Format an abbreviation as a word if the it is part of a longer class name.
- Examples:
ArrayList
, BigInteger
, ArrayIndexOutOfBoundsException
, Iterable
.
Method Names
Method names should typically be verbs or other descriptions of actions
- They should match the regular expression
^[a-z][a-zA-Z0-9]*$
.
- Use mixed case with the first letter in lower case.
- Examples:
toString
, hashCode
Variables
Variable names should be in mixed case with the first letter in lower case