Naming convention in Java

In java, when we assign name to identifiers such as class, package,method,variables etc. ,there are certain conditions which should be followed.It is not mandatory, but right way to do that.

It improves the readability of the code.

Name Convention Example
Class Name should be noun and start with uppercase. Try to keep name simple and descriptive. Class DataCheck
Method Name Should be verb. First letter should be lower case and any internal word should start with uppercase getData, runCase
Packages Packages Should be lowercase. Subsequent components may vary from organisation to organisation., com.sun.eng
interface name Should start with upercase MyInterface
variable name Should start with lowercase. Avoid using underscore_ and dollor sign$. int i, double myMoney
constants name Should be all uppercase. Separate words with underscore_ if more than one words. MIN_WIDTH, MAX_LENGTH, COLOR
Ask Question
If you have any question, you can go to menu ‘Features -> Q&A forum-> Ask Question’.Select the desired category and post your question.
Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...