Reserved Keywords

A reserved keyword are words reserved by Java that cannot be used as identifiers (e.g., variable names, method names, class names). If a reserved keyword was used as a variable you would get an error or unexpected result.

Here is a list of keywords that are reserved for use by the Java language:


  • abstract
  • assert
  • boolean
  • break
  • byte
  • case
  • catch
  • char
  • class
  • const
  • continue
  • default
  • do
  • double
  • else
  • enum
  • extends
  • final
  • finally
  • float
  • for
  • goto
  • if
  • implements
  • import
  • instanceof
  • int
  • interface
  • long
  • native
  • new
  • package
  • private
  • protected
  • public
  • return
  • short
  • static
  • strictfp
  • super
  • switch
  • synchronized
  • this
  • throw
  • throws
  • transient
  • try
  • void
  • volatile
  • while

Note that the keywords goto and const are C++ reserved keywords, but not currently used in Java. This enables the Java compilers to identify them and to produce better error messages if they appear in the Java program.

The literal values true, false, and null are not keywords, just like literal value 100. However, you cannot use them as identifiers, just as you cannot use the number 100 as an identifier.

What's Your Opinion?