Naming Conventions in Java



1) Package name in java are written in all small (lower) case letters

Ex: java.awt.
    java.io.
    java.swing.

2) Each word of classnames and interface names start with a capital.

Ex. String, DataInputStream, ActionListener.

3)Method names starts with a small letter if there is only the method name itself other wise leaving first each word the method start with a capital

Ex: println();
   readLine();
   getNumberInstance();

4) Variable names also follow the above rule

Ex: age, empName, employee_Net_Sal

5)Constants should be written using all capital letters.

Ex: MAX_VALUE.
   Font.BOLD

A constant represents a first value its value cannot be changed

Ex: pie-3.14 it can’t be changed , It is constant

–>  BOLD is the default (Constant) in Font class

Ex:       constant . constantname   we write like this in java

6) All Keywords should be written in all small letters

Ex:  public
    void
    int

Share with SociBook.com

Random Posts

Post a Comment