Guys, in this post we are going to discuss what is an identifier in java and let's see what are all the rules included in java identifiers. Identifiers are names given to variables, class, methods, objects, and interface in a program. It's a user-defined name. Identifiers should follow the following rules:
Example,
SUM is different from the sum.
Some examples fo valid indentifiers are:
Some examples of invalid identifiers are:
while - It's not an identifier because it's a java keyword.
94 - It's not an identifier because of its begins with alphabets.
roll no - Its not an identifier because it doesn't include space.
- Identifiers can have digits, alphabets, underscore and dollar sign characters.
- The first character must be an alphabet.
- They can be of any number of characters.
- They are case sensitive.i.e. upper case and lower case letters are different.
Example,
SUM is different from the sum.
Some examples fo valid indentifiers are:
A2,SUM,sum,c18,Balance_amount
Some examples of invalid identifiers are:
while - It's not an identifier because it's a java keyword.
94 - It's not an identifier because of its begins with alphabets.
roll no - Its not an identifier because it doesn't include space.
Also read: Java Keywords
No comments:
Post a Comment