Reserved Words in Java

Here's the full list of words you cannot use in Java

Businesswoman sitting at desk working on computer
Thomas Barwick/Stone/Getty Images

Reserved words are words that cannot be used as object or variable names in a Java program because they're already used by the syntax of the Java programming language.

If you do use any of the words below as identifiers in your Java programs, you'll get an error like you see at the bottom of this page.

List of Reserved Java Keywords


The strictfp keyword was added to this list in Java Standard Edition version 1.2, assert in version 1.4, and enum in version 5.0.

Even though goto and const are no longer used in the Java programming language, they still cannot be used as keywords.

What Happens If You Use a Reserved Word?

Let's say you try to create a new class and name it using a reserved word, like this:

 // you can't use finally as it's a reserved word!
class finally {
   public static void main(String[] args) {
      //class code..

Instead of compiling, the Java program will instead give the following error:

mla apa chicago
Your Citation
Leahy, Paul. "Reserved Words in Java." ThoughtCo, Apr. 10, 2018, Leahy, Paul. (2018, April 10). Reserved Words in Java. Retrieved from Leahy, Paul. "Reserved Words in Java." ThoughtCo. (accessed June 19, 2018).