Skip to main content

Identifier IN JAVA


Idenifiers:
Any Name in Java which is used for identifing Purpose is called as Identifier..
Ex:- className,VariableName,Method name,Constructor Name are Identifiers.

Rules for Identifiers:
1. Identifiers Can have alphanumeric Values and $ and _.
2. Identifiers can not start from Numbers..
3. Identifiers are Case sensitive.

4. There is no length Limit in Identifiers.
5. Pre-defined Keywords cant be used as an Identifiers.
6. Pre-defined Classname,Methodname,Interface Name,variable Name etc can be used as an Identifiers.


Recommendation:
1.
Pre-defined Classname,Methodname,Interface Name,variable Name etc should not be used as an Identifiers because it creates confusion.



CASE STUDY:

class Test
{
public static void main (String [] beast)
{

System.out.println("Test in progress");

int System=10;
System.out.println(a);
}
}


OUTPUT:


Compilation Error:


test.java:9: error: cannot find symbol


System.out.println(a);

^
symbol: variable a

location: class Test
test.java:9: error: int cannot be dereferenced
System.out.println(a);

Explanation:
Because System is Predefined Class name.It can be used as an identifier but then we cant use it is as Class Name identifier...



Comments