Easy To Learning
  • Login
  • Sign Up
  • Q&A
  • Home
  • Php Tutorial
  • MySql Tutorial
  • Object-Oriented Programming
  • Java Tutorial
  • HTML Tutorial
  • React JS Tutorials
  • Free Projects
  • Blogs & Articles
  • Others
    • About Us
    • Contact Us
Java Identifiers
Easy To Learning

Education Needs Complete Solution

Online Ask Question Question And Answer
  1. Home
  2. Java Tutorials
  3. Java Identifiers

Java Tutorial

Basic JAVA Fundamentals

  • JAVA Tutorial Content
  • What Is Java
  • History Of Java
  • Java Environment
  • Features Of JAVA
  • C++ Vs Java
  • Java Basic Syntax
  • First Program Of Java
  • Java Identifiers
  • Java Modifiers
  • Java Variable Types
  • Java Basic Datatypes
  • Java Keywords

Control Statements

  • Control Statements
  • Java If Else Statement
  • Nested If Statement In Java
  • Java Switch Statement

JAVA Loops

  • Loop In Java
  • For Loop In JAVA
  • Foreach Loop In JAVA

Java Identifiers

Java identifiers

  • 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.
  • Identifiers are the name given to variables, classes, methods etc. Consider the Below code;
int score;

Here, score is a variable (an identifier). You cannot use keywords as variable name. Its because keywords have predefined meaning. For example,

int float;

The above code is wrong. Its because float is a keyword and cannot be used as a variable name.

Example Of Java Identifiers

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.

Rules for Naming an Identifier

There are certain rules for defining a valid java identifier. These rules must be followed, otherwise, we get a compile-time error. These rules are also valid for other languages like C, C++.

  • An identifier 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.
  • Its convention to start an identifier with a letter rather and $ or _.
  • Whitespaces are not allowed.
  • Similarly, you cannot use symbols such as @, #, and so on.

Here are some valid identifiers:

score
level
highestScore
number1
convertToString
MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
easyto123

Here are some invalid identifiers:

class
float
1number
highest Score
@pple
My Variable  // contains a space
123easyto   // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character

 

Series: Java Tutorials Hub
All Topics
Free Download Projects
Previous Chapter
Next Chapter

Ask a Question

Have a coding query or doubt? Ask here and get help from our community.

500 characters remaining
Submitting...
Free Download Projects
Join Telegram Group Join WhatsApp Group
Related Topics:
java identifiers list what is a valid identifier in java? java identifiers rules identifiers in java easytolearning java identifiers are case sensitive identifiers in java tutorial literals in java identifiers expected java

Member Sign In

Forgot?
Signing in...

Don't have an account? Register here

Create Free Account

Register Captcha
Registering...

Already have an account? Sign In

Ask a Question

500 characters remaining
Submitting...

About Easy To Learning

Easy To Learning is a comprehensive programming learning portal offering free, practical, developer-driven tutorials for PHP, Java, Python, Spring, MySQL, CSS, Bootstrap, CakePHP, and more.

Explore community-contributed questions and answers, and download ready-to-run source code projects.

Quick Links

  • Home
  • Questions & Answers
  • Download Projects
  • Blog & Articles
  • Member Login

Community

  • Telegram Group
  • WhatsApp Community
  • Ask a Question
  • Join as Member

Connect With Us

Stay updated with our newest programming tutorials and free open source projects.

© 2026 Easy To Learning. All Rights Reserved.