In Java, reserved words are predefined identifiers that have a specific meaning in the language. They cannot be used as variable names, method names, class names, or identifiers, because they are part of the syntax of Java.

Java reserves some words to represent predefined functionalities. These words are called reserved words. They can be briefly categorized into two parts:
- Keywords (50): Keywords define functionalities. The table below shows a list of 50 keywords.
- literals (3): Literals define value. The three literals are true, false, and null.
Note: Identifiers in Java are stored in symbol tables and are used during the lexical, syntax, and semantic analysis phases of compilation.
List of Java Reserved Words
| Category | Keywords |
|---|---|
| Data Types | byte, short, int, long, float, double, char, boolean, void |
| Control Flow / Decision Making | if, else, switch, case, default, while, do, for, break, continue, return |
| Exception Handling | try, catch, finally, throw, throws |
| Modifiers | public, private, protected, static, final, abstract, synchronized, volatile, transient, native, strictfp |
| Object-Oriented Concepts | class, interface, extends, implements, this, super, new |
| Packages and Imports | package, import |
| Other Keywords | instanceof, enum, assert, goto, const |
Notes:
- goto and const are reserved but not used in Java. They exist only as keywords.
- assert is used for testing and debugging.
- Reserved words cannot be used as identifiers anywhere in the program.
Keywords vs Reserved Words
| Aspect | Keyword | Reserved Word |
|---|---|---|
| Definition | Predefined words with current functionality | Words set aside, including unused ones |
| Usage | Used in code for syntax and logic | Cannot be used as identifiers |
| Can be identifier? | Not allowed | Not allowed |
| Relation | All keywords are reserved words | Reserved words = keywords + future reserved words |
Examples | if, for, class, return, try | goto, const, and all keywords |
Related Article: