Java Identifiers

Identifiers is the name of a variable or a method or an array or a class or a package or an interface.

class Demo{
 void b(){
  int a=10;

In the above code

Demo is an identifier.

a is an identifier.

b is an identifier.

Rules of Identifier Naming

  • A valid identifier must have characters [A-Z] or [a-z] or numbers [0-9] and underscore(_) or a dollar sign($).
  • There should not be any space in an identifier.
  • An identifier should not contain a number at the starting.
  • An identifier should be length of 4-15 letters only. However there is no limits on its length. But, it is good to follow the standard conventions.
  • We can't use the Java reserved keywords as an identifier.

Example of Identifer


_angular ✔️

basic-course ❌


group. ❌

619 ❌

rush in bus ❌

over paid ❌

dontmind ✔️


hELLO ✔️

queue. ❌

team'svictory ❌

Plot # 2 ❌

2024_DDay ❌

Conventions for identifiers

1. Class/Interface Name(Title Case)
 class MyFirstClass{}

2. Method/Function(Camel Case)
 void myFirstMethod(){}

3. Package Name (Lower Case)

4. final/Constant(Upper Case)