Java Keywords

Java keywords are reserved words that have a specific meaning in the Java language syntax. These words are part of the language definition and cannot be used for naming variables, methods, classes, or any other identifiers.

What Are Java Keywords?

Keywords define the structure and control flow of a Java program. For example, keywords like class, if, while, and public are integral to writing Java code.

List of Common Java Keywords (Grouped by Purpose)

1. Access Modifiers

  • public
  • private
  • protected

2. Class and Interface Declaration

  • class
  • interface
  • extends
  • implements

3. Control Flow

  • if
  • else
  • switch
  • case
  • default
  • for
  • while
  • do
  • break
  • continue
  • return

4. Exception Handling

  • try
  • catch
  • finally
  • throw
  • throws

5. Primitive Data Types

  • int
  • float
  • double
  • char
  • boolean
  • byte
  • short
  • long

6. Other Important Keywords

  • static
  • final
  • void
  • new
  • this
  • super
  • abstract
  • synchronized
  • volatile
  • transient
  • native
  • strictfp
  • instanceof
  • enum
  • assert
  • package
  • import

Note: Words like true, false, and null are literals, not keywords—but they are also reserved and cannot be used as identifiers.

Important Rules

  • Keywords cannot be used as identifiers (variable, class, method names).
  • Java is case-sensitive, so Public and public are not the same—but only lowercase public is a keyword.