Skip to main content

Keywords

info

Keywords are simple english words which are having predefined meaning in Java Programming Language.

Key Points:

  • Meaning of these keywords can't be modified.
  • Keywords are also called Reservered Words.
  • All keywords are defined in lower case.
  • We can't use the keywords as names for variables, methods, classes, or any other identifiers.
  • true, false, null are not keywords, but reserverd as Literals.
  • There are 67 keywords defined upto Java 24.
  • const and goto are the keywords but no implementation available. You can't use these keywords in Java Program.
CategoryJava Keywords
Data Typesbyte, short, int, long, float, double, char, boolean, void
Class and Objectclass, interface, enum, record, new, this, super, instanceof
Access Modifierspublic, private, protected
Other Modifiersstatic, final, abstract, synchronized, native, strictfp, transient, volatile, sealed, non-sealed
Packages & Modulespackage, import, module, requires, exports, opens, provides, uses, with
Control Statementsif, else, switch, case, default, while, do, for, break, continue, return, yield
Exception Handlingtry, catch, finally, throw, throws
Flow & Behaviorassert, return, yield
Reserved (not used)const, goto

📝 Additional Notes:

  • Literals: true, false, and null are literals, not keywords.

  • Contextual Keywords:

    • var — introduced in Java 10 for local variable type inference (not a reserved keyword)
    • yield — Java 14+ switch expressions (reserved keyword now)
    • sealed, non-sealed, permits — Java 15+ (reserved keywords)