What is identifier in JAVA? What is identifier rules? - FindersAdda : Tutorials of Make Money, Computer or Internet

Monday, 20 November 2017

What is identifier in JAVA? What is identifier rules?

A name in java program is called identifier which can be user for identification purpose. It can be method name, variable name, class name or label name.

identifiers in java

In the above program, there are five identifiers such as Check, main, String, args and int.

There are following rules to define identifier.

(1) The identifier can be alphabet (lower and upper case), digits (0-9), dollar symbol and underscore symbol that means the only allowed character in java, identifiers are alphabet, dollar, digits, underscore.
E.g.: - Total_number, Total9

NOTE : - By mistake if you use any other immediately compiler gives compile time error.
Identifiers can’t start with the digits.

E.g.: - Total34 is valid but 34Total is not valid

(2) Java identifiers are case sensitive. Of course java language itself is treated as case sensitive programming language.

Int Number=10;
Int NUMBER = 10;
Int number = 10;

The above three variables are different not as same.

(3) There is no length limit for java identifiers but it is not recommended to take too lengthy identifiers.

(4) We can’t use reserve words as identifiers.

Int x=10; //it is valid
Int if = 10; // it is not valid

(5) All predefined java class names is an names. We can use as identifier interface.

class First
public static void main(String[] args)
{ int String = 3453;
int Runnable = 767;


output of above program

Even though it is valid but is not a good programming practice because it reduces readability and creates confusion.

There are given following identifier which is valid or not valid.

Valid identifier
Invalid identifier
Total #

Here, you are looking the below two identifiers Int and int. Int is valid because it is not reserve word but int is not valid because it is reserve word that means keyword.

I hope you liked this post so much. If you loved this post, so, share with your friends and also give some suggestion that what should i improve in this post. Thank You So Much......


About Author


Author & Editor

Myself Sumit Kumar Gupta & 21 year's old person. I am a programmer and blogger. I spend much more time on programming and blogging and helps other programmers and bloggers.


Post a Comment

We are eager to see your comments.
Comment Rule :

1. Don't use any link in the comment box. If you have any problem related to link then contact me with the contact form.

2. Don't use the wrong word if you write the wrong word in comment box then it will get spam.