DEV Community

Suma Sree
Suma Sree

Posted on

Let Us Learn Identifiers In Java.

A name of a programming element technically called as Identifier.
It can be class name,variable name,method name.
class _Example_{
int _student_=10;
void _m1()_{
}
}

  • Identifier is used for identifying programming element from other parts of the program or project.

  • Note:We can't create class or variable or Method without name which leads to compile time error:Identifier expected.

  • Rules in creating Identifier:
    We have 7 rules in creating an identifier
    1.Identifiers can contain letters[A-Z,a-z],digits[0-9],special characters only[$,].
    2.Identifiers can't start with digits but it can be used from second position onwards.
    3.Identifiers can't contain special characters except $,
    .
    4.Identifiers can't have space in the middle of characters.
    5.In Java Identifiers are case sensitive(a!=A).
    6.Reserve Words and Keywords can't be used as Identifiers.
    7.From java 9 onwords single underscore'_' can not be used as Identifier because it is a keyword.
    Note:We can use predefine class name,method name,variable name as user defined identifier and also there is no limit in the length of Identifier.

Top comments (0)