Home > Articles

This chapter is from the book

Identifiers and Keywords

Identifiers are used to name Java language entities. They begin with a Unicode letter, underscore character (_), or dollar sign ($). Subsequent characters consist of these characters and the digits 0–9. Identifiers are case sensitive and cannot be the same as a reserved word or the boolean values True or False or the null value. Avoid using the dollar sign character; it is intended for use by compiler-generated identifiers.

Know Your Java-Reserved Words

It is a good idea to memorize this list because you are likely to seeat least one exam-related question that requires knowledge of the preceding keywords. Also, remember that null, true, and false are literal values and not reserved keywords.

The following are examples of valid Java identifiers:

  • Identifier

  • $my_identifier

  • $123

The following are invalid Java identifiers:

  • 1badIdentifier

  • bad-too

  • %badID

The following words are reserved by the Java language and cannot be used as identifiers:

abstract do import return try
boolean double instanceof short void
break else int static volatile
byte extends interface strictfp while
case final long super

 

catch finally native switch

 

char float new synchronized

 

class for package this

 

const goto private throw

 

continue if protected throws

 

default implements public transient

 


Pearson IT Certification Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Pearson IT Certification and its family of brands. I can unsubscribe at any time.