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.
Category | Java Keywords |
---|---|
Data Types | byte , short , int , long , float , double , char , boolean , void |
Class and Object | class , interface , enum , record , new , this , super , instanceof |
Access Modifiers | public , private , protected |
Other Modifiers | static , final , abstract , synchronized , native , strictfp , transient , volatile , sealed , non-sealed |
Packages & Modules | package , import , module , requires , exports , opens , provides , uses , with |
Control Statements | if , else , switch , case , default , while , do , for , break , continue , return , yield |
Exception Handling | try , catch , finally , throw , throws |
Flow & Behavior | assert , 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)