Home » Core Java » Java Identifier Explained

About Simranjit Singh

Simranjit Singh
Simranjit Singh has graduated from Computer Science Department of the Guru Nanak Dev University of Amritsar, Punjab, India. He also holds a Master degree in Software Engineering from the Birla Institute of Technology & Science of Pilani, Rajasthan, India. He works as a Senior Consultant in the e-commerce sector where he is mainly involved with projects based on Java and Big Data technologies.

Java Identifier Explained

In this article, we will see examples of the identifier in the java programming language, which is a very important aspect of Programming.

1. Introduction

In C, C++, C#, Java, and other programming languages, an identifier is a name that is assigned by the user for a program element such as variable type, template, class, function, or namespace. It is usually limited to letters, digits, and underscores.

Java Identifier

Certain words, such as “new,” “int” and “break,” are reserved keywords and cannot be used as identifiers. Identifiers are used to identify a program element in the code. 

2. What is a Java Identifier?

In programming languages, identifiers are used for identification purpose.

In Java, an identifier can be a class name, method name, variable name or a label. It allows a programmer to refer to the item from other places in the program.

To make the most out of the identifiers you choose, make them meaningful and follow the standard Java naming conventions.

3. Java Identifier Examples

Identifiers must be composed of letters, numbers, the underscore and the dollar sign. Identifiers may only begin with a letter, the underscore or a dollar sign.

int score;

You cannot use keywords as variable names. It’s because keywords have predefined meanings, For example

int float;

Here, score is a variable (an identifier). It’s because float is a keyword and cannot be used as a variable name.

public class Test
    public static void main(String[] args)
        int a = 20;

In the above java code, we have 5 identifiers namely:

  • Test : class name.
  • main : method name.
  • String : predefined class name.
  • args : variable name.
  • a : variable name.

4. Java Identifiers Rules/Conventions

In Java, there are several points to remember about identifiers. They are as follows:

  • Identifiers cannot be a keyword.
  • Identifiers are case-sensitive.
  • It can have a sequence of letters and digits. However, it must begin with a letter, $ or _ .
  • The first letter of an identifier cannot be a digit.
  • It’s a convention to start an identifier with a letter rather and $ or _.
  • White-spaces are not allowed.
  • Similarly, you cannot use symbols such as @, #, and so on.

Some valid identifiers:

  • score
  • level
  • highestScore
  • number1
  • convertToString

Some invalid identifiers:

  • float
  • 1number
  • highest Score
  • @pple

5. Java Identifier – Summary

Identifiers in Java is a very important aspect of Programming. They are mainly used for Identification Purposes. Identifiers are a necessity as they make the program readable and efficient.

This article is contributed to enhancing your understanding of the Identifiers’ rules/conventions providing examples of valid identifiers.

0 0 vote
Article Rating

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area


Notify of
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x