What is an identifier?
Identifier:-
Identifier is the name of the basic programming elements.
Rules of an Identifier:-
While defining the identifier we must follow the below rules, or else it leads to compile time error.
1. Identifier should only contain
a.Alphabets.[a-z] to [A-Z]
b.Digits [0-9]
c.Special Character[ _ ,$]
Example:
These are Identifier
2. Identifiers should not start with a digit. A digit can be used from the second character onwards.
Example:
1stStudent--->This Syntax False
firstStudent--->This Syntax True
3. Identifier should not contain special character, only '_' and '$'
Example:
No#Stuent--->This Syntax False
No$Student--->This Syntax True
No_Student--->This Syntax True
4. Identifiers should not contain space in the middle of words. If we want to provide a gap between words, they must be connected with '_'.
Example:
First name--->This Syntax false
First_name--->This Syntax True
5. Keywords cannot be used as user identifiers because they are available throughout JVM directly
Example :
6. There is no limit to identifier length
0 Comments