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.test.app, 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.
OOPs concepts in java
Object and Classes
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *