1. Computing
Send to a Friend via Email

Reserved Words in Java


There are some words that you cannot use as object or variable names in a Java program. These words are known as “reserved” words; they are keywords that are already used by the syntax of the Java programming language.

For example, if you try and create a new class and name it using a reserved word:

 // you can't use finally as it's a reserved word!
 class finally {
    public static void main(String[] args) {
       //class code..
It will not compile, instead you will get the following error:
<identifier> expected 

The table below lists all the words that are reserved:

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

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

©2014 About.com. All rights reserved.