Language Fundamental

Identifier

A name in Java program is by default considered as Identifier and is use for identification purpose.
It can be a method name, variable name, class name or label name.


example:

class Test
{
public static void main(String args[])
{

System.out.println("Identifier");

int x = 10;

}

}


In a given Java program the underline text are identifier:

Test: Is a class name.

main: Is a method name called main() method.

String: Is a pre-defined class name.

args[] and x: Is a variable name.




While defining a Java identifier name we have some rules:

  1. a to z , A to Z , 0 to 9 , $ , _(underscore) are only word to use as a defining a name in Java language.
  2. A identifier should not start with digit.
  3. Java identifier are case sensitive.
  4. We cannot use Reserved word as identifier.
  5. We can also use pre-defined class name and interface name as a identifier but it is not recommended because it create a confusion and decrease the readability of program.




Question:How many character are allowed in Java Identifier?

Answer:There is no length limit for Java identifier but it is not recommended to take a too lengthy name.

example:

int xyzwerdndjd = 10; (this is valid but not recommended)










NEXT PAGE



PREVIOUS PAGE