Identifiers

  • April 27, 2022
  • Java
method overloading and method overriding

Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, functions, arrays, etc.

Identifier forming rules of Java state the following:
  • Identifiers can have alphabets, digits, and underscore and dollar sign characters.
  • They must not be a keyword or boolean literal or null literal.
  • They must not begin with a digit.
  • Furthermore, they can be of any length.
  • Java is case-sensitive, i.e, upper-case letters and lower-case letters are treated differently.

The following are some valid identifiers:

MyFile    A_to_Z
MYFILE    $1_abc
_CHK      file341

The following are some invalid identifiers:

DATA-REC    contains special character(-)
29fgt       Starting with a digit
break       reserved keyword
My.File     contains special character
Identifier naming conventions:

While making identifiers name, certain conventions are followed:

  • The name of public methods and instance variables should begin with a lowercase letter.
  • For names having multiple words, the second and subsequent words’ beginning character is made capital to enhance readability.
  • Private and local variables should use lowercase letters.
  • The class names and interface names begin with an upper case letter.
  • The constants should be named using capital letters and underscore.

Note: also read about the Token and keywords

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

https://www.instagram.com/coderz.py/

https://www.facebook.com/coderz.py

Leave a Reply

Your email address will not be published. Required fields are marked *