๐ŸŽ‰ Special Offer !    Code: GET300OFF    Flat โ‚น300 OFF on every Java Course
Grab Deal ๐Ÿš€

Keywords in Java  


Introduction

  • Keywords are the predefined, reserved words used by the Java compiler for specific operations.
  • There are total 50 keywords in Java, in which 48 keywords are actively used in programming and 2 reserved words (goto and const) that are not currently used in java.

Below is the list of all reserved words in java :-

Category Keywords
Data Types boolean, char, byte, short, int, long, float, double,
Control Statements if, else, switch, case, default, for, while, do, break, continue
Class/Interface class, interface, enum, extends, implements
Object Management new, this, super, null
Modifiers abstract, final, static, synchronized, transient, volatile
Package Management package, import
Access Modifiers public, private, protected
Return Type void, return
Exception Handling try, catch, finally, throw, throws, assert
Synchronization synchronized
Others native, strictfp, boolean, instanceof
Not Used goto, const

Characteristics of Keywords in Java:
  • Reserved Words: Keywords have specific meanings and are reserved for particular functions in the Java language.
  • Case-Sensitive: All keywords in Java are case-sensitive (e.g., class is a keyword, but Class is not).
  • Cannot be Identifiers: They cannot be used to name variables, methods, classes or other user-defined identifiers.
  • Enhance Readability: Keywords make the code easier to understand by providing a common vocabulary for developers.
  • Fixed Set: Java has a fixed list of keywords, and new ones are rarely added across versions.