Search
  • +44-7459919437 (UK- WhatsApp & Direct Call) | +91-6383544892 (India - WhatsApp Only) | Email Id : vinothrwins@gmail.com
Vinoth Tech Solutions
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I
  • Home
  • Selenium Java Online Training
  • Self Paced Video Course
    • Selenium Course Curriculum
    • Cypress Course Curriculum
    • Playwright Course Curriculum
  • Tutorials
  • Demo Sites
    • Practice Automation
      • Demo Page Healthcare
      • Registration Form
      • Transaction Details
      • DropDown
      • Mouse Event
      • Keyboard Events
      • Alert and Popup
      • Multiple Windows
      • iFrames
      • Wait WebElement
      • WebTable
  • FAQS
  • About Me & Feedback
    • Placed Students Feedback
    • Online Training Feedback
    • LinkedIn Profile
    • TechTalk
  • Free YouTube Courses
    • Python for Automation
    • Free QA Video Courses
      • Manual Testing
      • Java For Automation
      • Selenium Webdriver
      • TestNG
      • Cucumber BDD
      • UFT(QTP) Automation
    • Free Data Science Courses
      • Artificial Intelligence for Beginners
      • Python For A.I
      • Python Pandas
      • Python NumPy
      • Mathematics for A.I

Java For Automation

  • What is Java?
  • Why to Learn Java?
  • History of Java
  • Types of Java Applications
  • Naming Conventions
  • Hello World Program
  • Internal Details of Java program
  • What is Java JDK, JRE and JVM ?
  • What is Java Comments ?
  • What is Java Variable?
  • Variable Naming convention
  • Primitive Data Types
  • Non Primitive Data Types
  • Type Casting
  • Java Arithmetic Operators
  • Relational Operators
  • What is logical operators in Java? 
  • What is Assignment Operators in Java? 
  • What is Unary Operators in Java? 
  • What is Ternary Operators in Java?
  • What is Java Control Statements?
  • What are Decision Making statements?
  • What are looping statements?
  • What are Jump statements?
  • What is OOPS concept in Java?
  • Advantages of Java OOPs
  • What is Java Inheritance?
  • What is Java Constructor?
  • What is this keyword?
  • What is Polymorphism?
  • What is super keyword ?
  • What is final keyword? 
  • What are access modifiers?
  • What is Encapsulation? 
  • What is Abstraction? 
View Categories
  • Home
  • Tutorials
  • Java
  • Java For Automation
  • Naming Conventions

Naming Conventions

Naming Conventions

Naming conventions in Java are crucial for writing clear, readable, and maintainable code. They help in understanding the purpose of different elements within the code and ensure consistency across projects and teams. Here are the common naming conventions for various elements in Java:

1. Classes #

  • Convention: Class names should be in PascalCase (also known as UpperCamelCase).
  • Rule: The first letter of each word is capitalized.
  • Example: CustomerAccount, EmployeeDetails, LinkedList.

2. Interfaces #

  • Convention: Interface names should also be in PascalCase.
  • Rule: They often describe a capability or behavior.
  • Example: Runnable, Comparable, Serializable.

3. Methods #

  • Convention: Method names should be in camelCase.
  • Rule: The first letter of the first word is lowercase, and the first letter of each subsequent word is capitalized.
  • Example: getName(), calculateTotal(), processData().

4. Variables #

  • Convention: Variable names should be in camelCase.
  • Rule: The first letter of the first word is lowercase, and the first letter of each subsequent word is capitalized.
  • Example: firstName, totalAmount, employeeList.

5. Constants #

  • Convention: Constants should be in all uppercase letters with words separated by underscores.
  • Rule: They are usually declared as static final.
  • Example: MAX_VALUE, DEFAULT_TIMEOUT, PI.

6. Packages #

  • Convention: Package names should be in all lowercase letters.
  • Rule: They often start with the top-level domain name followed by the company name and project or module name.
  • Example: com.example.project, org.openai.chatgpt.

7. Annotations #

  • Convention: Annotation names should be in PascalCase.
  • Rule: The first letter of each word is capitalized.
  • Example: @Override, @Deprecated, @SuppressWarnings.

8. Enums #

  • Convention: Enum names should be in PascalCase.
  • Rule: The first letter of each word is capitalized, and enum constants are usually in all uppercase letters with words separated by underscores.
  • Example: public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }

9. Type Parameters #

  • Convention: Type parameter names should be single, uppercase letters.
  • Rule: Commonly used letters are T for type, E for element, K for key, V for value, and so on.
  • Example: public interface Comparable<T>, public class HashMap<K, V>.

Example Code #

Here’s an example demonstrating these conventions in a simple Java program:

package com.example.project;

public class CustomerAccount {

    private String firstName;
    private String lastName;
    private static final int MAX_CREDIT_LIMIT = 10000;

    public CustomerAccount(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public static int getMaxCreditLimit() {
        return MAX_CREDIT_LIMIT;
    }
}

interface Printable {
    void print();
}

enum Status {
    NEW, PROCESSING, COMPLETED, FAILED
}

Summary #

  • Classes and Interfaces: PascalCase.
  • Methods and Variables: camelCase.
  • Constants: All uppercase with underscores.
  • Packages: All lowercase.
  • Annotations: PascalCase.
  • Enums: PascalCase for enum types, all uppercase for enum constants.
  • Type Parameters: Single uppercase letters.

By adhering to these conventions, Java code becomes more standardized and easier to read, maintain, and understand.

Java
What are your Feelings
Share This Article :
  • Facebook
  • X
  • LinkedIn
Types of Java ApplicationsHello World Program
Table of Contents
  • 1. Classes
  • 2. Interfaces
  • 3. Methods
  • 4. Variables
  • 5. Constants
  • 6. Packages
  • 7. Annotations
  • 8. Enums
  • 9. Type Parameters
  • Example Code
  • Summary
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105