Reserved Words in Java

Last Updated : 6 Oct, 2025

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.

reserved_words_53_

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

CategoryKeywords
Data Typesbyte, short, int, long, float, double, char, boolean, void
Control Flow / Decision Makingif, else, switch, case, default, while, do, for, break, continue, return
Exception Handlingtry, catch, finally, throw, throws
Modifierspublic, private, protected, static, final, abstract, synchronized, volatile, transient, native, strictfp
Object-Oriented Conceptsclass, interface, extends, implements, this, super, new
Packages and Importspackage, import
Other Keywordsinstanceof, 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

AspectKeywordReserved Word
DefinitionPredefined words with current functionalityWords set aside, including unused ones
UsageUsed in code for syntax and logicCannot be used as identifiers
Can be identifier?Not allowedNot allowed
RelationAll keywords are reserved wordsReserved words = keywords + future reserved words

Examples

if, for, class, return, try

goto, const, and all keywords

Related Article:

Java Keywords


Comment