Identifiers and Literals
Identifier
An Identifier is needed to name a variable.
An identifier is sequence of character, of any length, comprising uppercase and lowercase letters (a-z, A-Z), digits (0-9z), underscore _ and dollar sign $.
Java imposes the following rules on identifiers
- White space (
blank, tab, newline) and other special characters (such as +, -, *, /, @, &, commas, etc.) are not allowed.
- An identifier must begin with letter (
a-z, A-Z) or underscore (_).
- It cannot begin with digits (
0-9).
- Identifiers begin with dollar sign
$ are reserved for system-generated entities. So, you can not use it.
- An identifier cannot be a reserved keyword or a reserved literals (e.g.
class, int, double, if, else, for, true, false, null).
- Identifiers are case sensitive. A Tutorialink is not same as TUTORIALINK and tutorialink.
Literals
- A literal is a specific constant value or raw data, such as 123, -456, 3.14, 'a', "hello", that is used in the program source.
- They are called literals because they literally and explicitly identify their values.
- It can be of any Java data types.
Ask Question