Identifier:
A name in java program is called identifier. It can be class name,
variable name, method name, label name.
Ex:
class Ab //Ab is identifier {
public static void main(String args[]) //main is identifier
{
public void m1(){ //m1 is identifier
public void m1(){ //m1 is identifier
int a=12;//a is identifier label 1://identifier
for (int i=0; i<5; i++)
{ if(i==2){
break;
}
break;
}
}
Rules:
1:- The only allowed
characters in java for identifiers are:
a> a-z, b> A-Z, c> 0-9 and _,$.
NOTE: - If we are using other
characters then we’ll get compile time error.
Ex: a>
all_Inmember (YES) b> _123ab
(YES) c> abc@(No) d>123foo (No)
2:-
Java Identifiers can’t start with digits.(Like 123va is wrong).
3:-Java Identifiers are case sensitive.(Like
int Num=12 is different from int num=12).
4:-There is no limit for the java identifiers but recommended length for
java identifier is less than 15
5:-Reserved words can’t
be used as identifiers.
6:-
All predefined class name and interface name can be used as identifier even it
is legal but it is not recommended.
class T { int
Spring=12;System.out.println(Spring);//not recommended.
Spring Runnable=”java”;//not recommended.}
0 Comments