-
Notifications
You must be signed in to change notification settings - Fork 0
Language Fundamentals
Rohit Agarwal edited this page Jul 9, 2017
·
1 revision
A name in java program is called identifier which can be used for identification purpose. It can be a method name, variable name, class name or label name.
Example - How many identifiers are presents in the following program.
class Test{
public static void main(String[] args){
int x=10;
}
}
Answer - There are 5 identifiers present Test, main, String, args, x.
-
The only allowed characters in Java identifiers are a to z, A to Z, 0 to 9, $, _. If we are using any other character we will get compile time error. Ex - Total_number - Valid , Total# - Invalid
-
Identifiers can't start with a digit. Ex - Total123 - Valid, 123Total - Invalid
-
Java Identifiers are case sensitive because Java language itself is treated as case sensitive programming language.
Ex
class Test{
//Differentiated w.r.t case
int number = 10;
int Number = 10;
int NUMBER = 20;
}