A name in Java program is called identifier,it can be class name or variable name or method name or lable name.
Example.
👉 Rules of define indentifiers
- The only allowed charaters in Java indentifiers are:
- A to Z
- a to z
- 0 to 9
- hyphen(-)
- dollar($)
- if we are using any other characters we will get completime error.
public class Main {public static void main(String[] args) {// Goodint 455 = 60;// OK, but not so easy to understand what m actually isint m = 60;System.out.println(455);System.out.println(m);}}
OUTPUT
3. Indentifiers can't start with digit.
Ex.
123abc - Error
abc123 - Ok
4. Java identifiers is casesensitive
Ex.
Class Test
{
int Number = 10;
int Number = 20;
int Number = 30;
}
5. Reserved words can't be used as identifiers (like a java keyword, such int or boolean).
6. There is no limit for java indentifiers. But it's not recommanded to take morethan 15 lenght . (>15)
7. all predefined java class names & interface name we can use as indetifiers. Eventhough it is legel but it is not recommanded.
Tags:
Java


