Java Naming Convention

  • Java Naming Convention is a rule to follow as you decide what to name your identifier such as class ,package,variable,constant,method etc.
  • But it is not forced to follow.So,it is known as convention not rule.
  • All the classes,package,method,interface and field of java programming language are given according to java  naming convention

 

Major naming convention in java-

  • package in java should be in small letter as java.lang.
  • Each word of interface should start with capital letter as Serializable.
  • Each word of classes should start with capital letter as Country.
  • Method name should be in small leter as println().
  • Constant should be in all capital letter like MAX_VALUE
  • Variable name should be start with capital letter and change as per word change.
Name  Convention
class should start with uppercase letterand be an noun.Ex-String,Color,System
interface neme should start with upper case letter and be an adjective.Ex-Runnable,Remote
method name should start with upper case letter and be an verb.Ex-print(),main()
variable name should start with lower case letter.Ex-firstname,secondname
package name should start with lower case letter.Ex-java ,lang,sql
constant name should start with uppercase letter.Ex-RED,YELLOW