Java Identifiers

preview_player
Показать описание
Identifier :
A name given in java program is called identifier.

Rules to define java identifier :
1)Rule 1 : The only allowed characters in java identifiers are :
1) a to z
2) A to Z
3) 0 to 9
4) _ underscore
5) $

2)Rule 2 : If we are using any other character we will get compile time error
eg.
1) total_number---------valid
2) Total#----------------invalid

3)Rule 3 : Identifier are not allowed to start with digit
eg.
1) ABC123---------------valid
2) 123ABC---------------invalid

4)Rule 4 : java Identifier are case sensitive upcource java language are case sensitive language.
eg.
Class Test{
int number = 10;
int Number = 20;
int NUMBER = 30;
int NuMbEr = 40;
}
5)Rule 5 : We cant use reserved words as identifiers.
eg.
1) int if = 10;-------------invalid

6)Rule 6 : There is no length limit for java identifiers but it is not recommended to take more than 15 lengths.

7)Rule 7 : All predefined java class names and interface names we use as identifiers.

eg1.

public class Identifier {

public static void main(String[] args) {
int number = 10;
int Number = 20;
int NUMBER = 30;
int NuBeR = 40;

int String = 10;

int Runnable = 20;

}

}
Рекомендации по теме
Комментарии
Автор

I will never forget about identifier Thank u mahesh sir

mauligherade