Java Keywords
Java keywords are reserved words that have a specific meaning in the Java language syntax. These words are part of the language definition and cannot be used for naming variables, methods, classes, or any other identifiers.
What Are Java Keywords?
Keywords define the structure and control flow of a Java program. For example, keywords like class, if, while, and public are integral to writing Java code.
List of Common Java Keywords (Grouped by Purpose)
1. Access Modifiers
publicprivateprotected
2. Class and Interface Declaration
classinterfaceextendsimplements
3. Control Flow
ifelseswitchcasedefaultforwhiledobreakcontinuereturn
4. Exception Handling
trycatchfinallythrowthrows
5. Primitive Data Types
intfloatdoublecharbooleanbyteshortlong
6. Other Important Keywords
staticfinalvoidnewthissuperabstractsynchronizedvolatiletransientnativestrictfpinstanceofenumassertpackageimport
Note: Words like
true,false, andnullare literals, not keywords—but they are also reserved and cannot be used as identifiers.
Important Rules
- Keywords cannot be used as identifiers (variable, class, method names).
- Java is case-sensitive, so
Publicandpublicare not the same—but only lowercasepublicis a keyword.