JAVA Identifiers
A name in java program is called identifiers. It may be a class name, method name, variable name, and label name.
class Test
{
public static void main(string[] args)
{
int x = 10;
}
}
*Text in red color are identifiers.
Rules to define Java Identifiers:
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) $
Rule 2: If we are using any other character we will get a compile-time error.
1) total_number ----------> Valid
2) Total# ----------> Invalid
Rule 3: Identifiers are not allowed to starts with digits:
1) ABC123 -----------> Valid
2) 123ABC ------------> Invalid
Rule 4: Java identifiers are case sensitive up course java language itself treated as case sensitive language.
Rule 5: There is no length limit for java identifiers but it is not recommended to take more than 15 lengths.
Rule 6: We can't use reserved words as identifiers.
Comments
Post a Comment