Dec 16, 2008

Identifiers in Java

Some points about Identifiers
  1. A name in a program is called an identifier.
  2. An identifier is sequence of characters which can be a letter, digit, connecting characters (Underscore _) or a currency symbol ($, ¢, ¥ or £).
  3. Identifier cannot start with a digit, after first character digits are allowed.
  4. Identifiers in java are case sensitive i.e. test and Test are two different Identifiers.
  5. Identifier can be of any length
  6. Keywords cannot be used as an Identifier.

Illegal Identifier

  1. 45abcd – Starting with a digit
  2. abcd@efgh – @ is not allowed
  3. new – Keyword not allowed

Legal Identifier

  1. $$ – $ is allowed
  2. Ab88cd – Digits are allowed after first character.
  3. Abc_88 – Underscore is a valid connecting character.

No comments:

Post a Comment