Keywords are reserved words in the language. These keywords cannot be used as variable names or constants or identifiers. Following table shows the type and their corresponding keywords:


Access Modifiers

private, public, protected

Flow Control

break, case, continue, default, do, else,  for, if, instanceof, return, switch, while

Package control

import, package

Error handling

assert, catch, finally, throw, throws, try

Primitive types

boolean, float, int, char,long, shorfinalt,byte, double

Class, method, variable modifiers

abstract, class, default, extends,implements, interface, native, new,  static, strictfp, synchronized, transient,  var, record, volatile




super, this, void


const, goto

Reserved Identifiers:

Here are some of the identifiers which are not the keywords but still they are restricted up to some extent:

  • permits: This is a clause that specifies the classes permitted to extend a given sealed class.
  • sealed: A sealed class is like an interface that can only be implemented or developed by the interface or classes allowed for it.
  • record:
  • var: It is a unique identifier that we cannot use as a type name in Java.
  • yield: It is mainly used for setting a value for any switch expression.

Reserved literal values:

  • true: It is a literal value of type Boolean.
  • false: It is a literal value of type Boolean.
  • null: It is a reference type of literal value.

Example :

public class Main { public static void main(String[] args) { //Boolean keyword boolean isJavaFun = true; boolean isFishTasty = false; System.out.println("Knowledge2life "+ isJavaFun); System.out.println("Knowledge2life "+isFishTasty); //Double keyword double myNum = 19.99d; System.out.println(myNum); //Float Keyword float myNum1 = 5.75f; System.out.println(myNum1); } }


Knowledge2life true
Knowledge2life false