A name in the program is an identifier it may be class name or method name,variable name or label name.
Ex:-
Rules for defining Identifiers
1) A java identifier is a sequence of characters, where each character may be a letter from a-z or A-Z
or a digit form 0-9 or currency symbol $ or connecting punctuation – , if we are using any other
symbol we will get Compile time error “IllegalCharacter”.
2) Identifier should not be starts with digit.
3) There is no length limit for java identifiers but it is not recommended to take more than 15
length.
4) Java Identifiers are case sensitive
Ex:
class FundaDemo
{
public static void main(String[] args)
{
int String = 10;
System.out.println(String);
}
}
O/P:- 10
Which of the following are valid Identifiers
1) total#
2) all@hands
3) 123total
4) break
5) String
6) total_number
7) $_$
8) $ca$h
Reserved Words
Ex:-
Rules for defining Identifiers
1) A java identifier is a sequence of characters, where each character may be a letter from a-z or A-Z
or a digit form 0-9 or currency symbol $ or connecting punctuation – , if we are using any other
symbol we will get Compile time error “IllegalCharacter”.
2) Identifier should not be starts with digit.
3) There is no length limit for java identifiers but it is not recommended to take more than 15
length.
4) Java Identifiers are case sensitive
Ex:
class FundaDemo
{
public static void main(String[] args)
{
int String = 10;
System.out.println(String);
}
}
O/P:- 10
Which of the following are valid Identifiers
1) total#
2) all@hands
3) 123total
4) break
5) String
6) total_number
7) $_$
8) $ca$h
Reserved Words