/* related posts with thumb nails */

Naming conventions followed in Java:

Naming Convention: Naming conventions are a set of rules to be followed to give names to the variables, classes and other tokens of a Java program. It is a better programming practice to follow the naming conventions. One can easily differentiate or understand what are classes, what are methods and etc. It facilitates easy reference i.e. when one refers back to a program, one can easily understand what is what. These are not mandatory but suggested. The following are the naming conventions suggested in Java.

1. Package names in java are written in all small letters

Example: java.awt, java.io, javax.swing , java.mypackage

2. Each word of a class name and interface name starts with a capital letter.

Example: String, DataInputStream, ActionListener

3. Method names starts with a small letter, then each word that follows starts with a capital letter.

Example: readLine( ) , toCharArray()

4. Variable names also follow the above rules as those of methods; words may be separated by underscores (_).

Example: age, empName, employee_Net_Sal;

5. Constants should be written using all capital letters, words are separated by underscores (_) .

Example: PI, MAX_VALUE

6. All key words should be written in all small letters.

Example: public, static, void, main etc…

Related Topics:


Post a Comment