Naming Convention


We should use standard java naming conventions to make our code easier to read for ourself as well as for other programmers.

In Java, we follow CamelCase syntax for naming our class, interface, method and variable.

Note: If a name is combined with two words then the second word will always starts with an uppercase letter, e.g. firstName, myMethod(), ActionListener etc.


  • Class Names: All the class names should start with first letter in Upper Case.

    Example: class MyJavaClass

  • Method Names: All the method names should start with a Lower Case letter.

    Example: public void myMethodName()

  • Variable Name: A variable name should start with a Lower Case letter.

    Example: String firstName , lastName;

  • Constant Name: A constant name should be in completely uppercase letters.

    Example: PI, TUTORIAL

  • Interface Name: An interface name should start with first letter in Upper Case.

    Example: Bank , ActionListener

  • Package Name: A package name should be in completely lowercase letters.

    Example: lang, util, sql

  • Program File Name: The name of a program file should exactly match the class name. When saving a file, we should save it using the class name with “.java” extension.

    Example: Assume 'MyProgram' is the name of the class then the file should be saved as 'MyProgram.java'

Note: If the file name and the class name do not match then your program will not compile.