Java Naming Convention

This tutorial will provide a deep knowledge on class, method, variable and interface Java Naming Convention.

Classes and Interfaces

  1. Class must match the name of file.
  2. As a best practice, the class name must be mixed case and first letter should always be capital.
  3. The class name should not contain any whitespace.
  4. Class name should not start with special characters.

Syntax:

class Employee {
    
}

Methods:

As a best practice, method name should be mixed case and always start with small case letter.

e.g. -> start(), getEmployeeName(), getEmployeeId()

Syntax:

class Employee {
public void start() {

}
public void getEmployeeName() {

}
public void getEmployeeId() {

}
}

Variables

  1. As a best practice, method name should be mixed case and always start with small case letter.

e.g. -> name, age, firstName, lastName

2. variable name should not start with special characters.

3. Static variables name should always be start with capital and separate every word by underscore.

Syntax:

class Employee {
    String name;
    int age;
    String firstName;
    String lastName;
    public static String UNIVERSITY_NAME; // static variable
}

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan