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
  • Variable Naming convention

Variable Naming convention

Variable Naming convention 

In Java, following proper naming conventions for variables is crucial for writing readable and maintainable code. The naming conventions are guidelines that help ensure consistency across different codebases, making it easier for developers to understand and collaborate on projects. Here are the key conventions for naming variables in Java:

General Guidelines #

Use Meaningful Names: Variable names should be descriptive and indicate the purpose of the variable. Avoid using single letters or obscure abbreviations.

int age;           // Good
int a;             // Bad
double salary;     // Good
double sal;        // Bad

  1. Camel Case Notation: Use camel case for variable names, where the first word is in lowercase and each subsequent word starts with an uppercase letter.

int employeeCount;   // Good
int employeecount;   // Bad
int employee_count;  // Bad

2. Avoid Reserved Words: Do not use Java reserved keywords as variable names.

int class;    // Bad
int public;   // Bad

3. Start with a Letter: Variable names should start with a letter (a-z, A-Z) or an underscore (_), and not with a digit.

int age;       // Good
int _age;      // Not advised to use 
int 1age;      // Bad

4. Case Sensitivity: Remember that Java is case-sensitive, so age and Age would be considered different variables.

int age;
int Age;      // Different variable from `age`

5. Constant Variables: Use all uppercase letters with words separated by underscores. Constants are typically declared using the final keyword.

static final int MAX_USERS = 100;
static final double PI = 3.14159;

Good Naming Conventions:

int numberOfStudents;
double averageTemperature;
String customerName;
final int MAX_RETRIES = 5;

Bad Naming Conventions:

int num;              // Not descriptive
double avgTemp;       // Use full words for clarity
String CustName;      // Avoid capitalizing the first letter
final int MAXRETRIES; // Separate words with underscores for constants

Summary #

  • Descriptive Names: Choose names that clearly describe the variable’s purpose.
  • Camel Case Notation: Use camel case for variable names.
  • Avoid Keywords: Do not use Java reserved keywords as variable names.
  • Start with a Letter: Begin variable names with a letter or underscore.
  • Case Sensitivity: Be aware that Java is case-sensitive.
  • Constants: Use all uppercase letters with underscores to separate words for constants.

By adhering to these naming conventions, you can ensure that your code is more readable, maintainable, and easier for others to understand and work with.

Java
What are your Feelings
Share This Article :
  • Facebook
  • X
  • LinkedIn
What is Java Variable?Primitive Data Types
Table of Contents
  • General Guidelines
  • Summary
© 2018 – 2025 Vinoth Tech Solutions Ltd (UK), Reg. No: 16489105