Identifiers
Let us see a quick definition of identifiers. It is as easy as you expect the name itself has its definition. Identity (ers) means these are words that are used to identify something. In software terms, we are using these identifiers as the class name, method name, variable name or it can be a label. In future posts, we will see all these in detail.
Let us see with our basic program
class Display { public static void main(String[] args) { int a = 10; String b = "Variable value is " System.out.println(b + a) } }
Below are the identifiers that are present in the above-mentioned program
- Display - Class name
- main - Method name
- String - Predefined class name
- args - Variable name
- a - Variable name
- System - Predefined class name
- out - Predefined variable name
- println - Method name
******Identifiers are case sensitive******
There are some regulations in using identifiers let us see in detail
Valid Identifiers
- Can use alphanumeric - (A-Z,a-z,0-9)
- Can use a dollar sign and underscore - ( $, _ )
Example: display, Display, $display, $, _display
Invalid Identifiers
- Identifiers should not start with numbers(0-9)
- Other than $ and _ no other special characters are valid for identifiers
- Identifiers should not be Reserved Words
- Should not use space in between the same identifier
Example: 1display, Display new, @display, if, while, for, etc..,
Hope you are clear on the java identifier
Feel free to post your queries!!!
Next Java Modifiers
Comments
Post a Comment