Keywords in Java | Reserved Keywords

Keywords in Java are predefined words that have specific meanings to the compiler and that meanings cannot be changed.

Since keywords have specific meaning in Java language, we cannot use them as names of classes, variables, methods, and so on.

Since Java is a case-sensitive language, all keywords must be written in lowercase letters (small letters).

List of Reserved Keywords in Java


Since keywords are an essential part of a language definition, Java language has currently reserved 50 words as keywords and these keywords are called reserved keywords.

These reserved keywords combine with operators and separators according to syntax and create the definition of Java language. Therefore, Java programmers should understand the meaning of all these reserved words.

The list of the reserved keyword is as follows:

a) Data Type: Java language has reserved eight words as keywords for data types that are as follows:

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

b) Access Modifiers: There are three reserved words as keywords for access modifiers by Java language. They are as follows:

  • private
  • protected
  • public

These keywords are called access modifier keywords.

c) Control Statement: There are ten reserved words as keywords for the control statement by Java language. They are as:

  • else
  • switch
  • case
  • default
  • for
  • while
  • do
  • continue
  • break
  • goto [reserved but not in used]
  • if

d) Object and Classes: There are seven reserved keywords for classes and objects by Java language. They are as follows:

  • class
  • interface
  • extends
  • implements
  • this
  • super
  • new

e) Modifiers: There are eight modifier keywords reserved in the Java language. These keywords are also called non-access modifier keywords. They are as follows:

  • static
  • abstract
  • synchronized
  • volatile
  • native
  • transient
  • strictfp
  • final

f) Exceptions: There are five exception keywords that are reserved by Java language. They are as:

  • try
  • catch
  • finally
  • throw
  • throws

g) Package: Java language has included two reserved keywords for a package that is as follows:

  • package
  • import

h) Miscellaneous keywords:

  • return
  • const (*)
  • instanceof
  • void
  • assert
  • default
  • enum

The keywords const and goto are reserved but not used. In addition to these keywords, Java reserves the following: null, true, and false.

These are values that are defined by Java language. We may not use these words for the names of classes, variables, methods, and so on.

Hope that this tutorial has covered almost all the important points related to reserved keywords. I hope that you will have understood these reserved words and kept them in mind.
Thanks for reading!!!
Next ⇒ Identifiers in Java

⇐ Prev Next ⇒