How to Name a Class in Java
The best is to use a single short word that must be a noun ("a name of thing")., Always start the class name with capital letter (this is different from how the variables are named). , Do not use underscore to separate multiple words in a Java class...
Step-by-Step Guide
-
Step 1: The best is to use a single short word that must be a noun ("a name of thing").
Do not use a single verb or single adjective.
The selected word should reflect the purpose of the class.
If it is not possible to name the purpose of the class clearly with a single noun, add more words using Camel casing (like BorderLayout).
Adjectives are best suitable as extra words as they naturally give more information about the noun. -
Step 2: Always start the class name with capital letter (this is different from how the variables are named).
,,, -
Step 3: Do not use underscore to separate multiple words in a Java class name (it is a rule of C++ programming).
-
Step 4: Only use all uppercase names if they directly come from the known abbreviation (URL
-
Step 5: UUID and so on).
-
Step 6: Always place a class into some package.
Detailed Guide
Do not use a single verb or single adjective.
The selected word should reflect the purpose of the class.
If it is not possible to name the purpose of the class clearly with a single noun, add more words using Camel casing (like BorderLayout).
Adjectives are best suitable as extra words as they naturally give more information about the noun.
,,,
About the Author
Diane Campbell
Dedicated to helping readers learn new skills in practical skills and beyond.
Rate This Guide
How helpful was this guide? Click to rate: