Page 59 - iprime_V2.2_class8
P. 59
Identifiers
An identifier is the name given to an object in a Java program. It is used to uniquely identify an
object in a program, such as, a class name or a method name.
Rules for Naming Identifiers
The rules for naming identifiers are:
Can consist of letters, digits 0–9, underscore ( _ ), and dollar ($) sign.
Cannot start with a digit.
Keywords cannot be used.
No special symbols like !, @, #, %, etc. can be used.
Identifiers are case-sensitive, which means ‘name’ and ‘NAME’ are two different identifiers.
Examples of some valid identifier names are Employee123, mygood_book, _address93, FirstName,
age, etc.
Examples of some invalid identifier names are 1_Name, @Address, 1234, –Age, etc.
Keywords
Keywords are reserved words that cannot be used as identifiers because they have a special
meaning for the Java compiler. Some of the Java keywords are given below:
Java Keywords
abstract class final interface static
assert const float long switch
boolean continue for new this
break default if private throw
byte do implements protected throws
case double import public try
catch else instanceof return void
char extends int short while
Although reserved as a keyword in Java, const is not used and has no function.
Additionally, there are three more reserved words in Java: true, false, and null. Technically, these
are literal values rather than keywords. However, they cannot be used as identifiers and have
specific meanings for the Java compiler.
If Excel was a magical library, how would you sort books and filter books you
had read?
Program Coding 57

