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.

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:

abstractdoimportreturntry
booleandoubleinstanceofshort

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.