This page supports the two keyword tables below by explaining what the keywords do, how they group together conceptually, and how modern Java (17 → 25) uses them in real code. The actual list of reserved keywords has been stable across Java 17 through Java 25; what’s changed is how you use them, e.g., pattern matching with instanceof, modern switch expressions, records, and sealed hierarchies.
true, false, and null are literals (not operators or identifiers). const and goto are reserved but unused.var, record, sealed, permits, or yield in examples. They are treated specially by the language and tooling, but they don’t change the classic table here. Your project’s compiler level determines availability/meaning.class, interface, enum: define reference types.extends, implements, super, this, new: inheritance, contracts, and object construction.package, import: namespace and visibility across compilation units.native: methods implemented in non-Java code (JNI).public, protected, private: API surface and encapsulation.final, static, abstract: inheritance and initialization semantics.transient, volatile, strictfp: serialization, memory model hints, and legacy FP consistency.synchronized: intrinsic locking for critical sections.if, else, for, while, do: fundamental branching and looping.switch, case, default: now powers switch expressions (concise and often more readable for selections).break, continue, return: exits for loops and methods.try, catch, finally, throw, throws: structured error handling (incl. try-with-resources).assert: runtime checks enabled with -ea for testing/invariants.boolean, byte, short, int, long, char, float, double.true, false, null.instanceof: type checks—now with pattern matching to bind a typed variable directly.instanceofPattern variables let you combine the check and cast safely.
// Java 17+
Object value = getValue();
if (value instanceof String s) {
System.out.println("Upper: " + s.toUpperCase());
}
Automatically closes resources that implement AutoCloseable.
try (var reader = java.nio.file.Files.newBufferedReader(path)) {
System.out.println(reader.readLine());
} catch (java.io.IOException e) {
// handle or rethrow
}
switchSwitch expressions (available in current JDKs) make selection logic simpler and less error-prone.
// Example shape area with modern switch (concise form)
double area = switch (shape.type()) {
case CIRCLE -> Math.PI * shape.radius() * shape.radius();
case RECT -> shape.width() * shape.height();
case TRIANGLE -> shape.base() * shape.height() / 2.0;
};
var for local inference: A convenience for local variables. It’s not a traditional keyword in the classic list, but you’ll see it widely in examples.The following two tables enumerate the classic reserved keywords and related reserved words. Use the explanations above to map each keyword to its role in real code.
| abstract | assert | boolean | break |
| byte | case | catch | char |
| class | const | continue | default |
| do | double | else | enum |
| extends | false | final | finally |
| float | for | goto | if |
| implements | import | instanceof | int |
| interface | long | native | new |
| null | package | private | protected |
| public | return | short | static |
| strictfp | super | switch | synchronized |
| this | throw | throws | transient |
| true | try | void | volatile |
| while |
| abstract | default | goto | package | this |
| assert | do | if | private | throw |
| boolean | double | implements | protected | throws |
| break | else | import | public | transient |
| byte | enum | instanceof | return | true |
| case | extends | int | short | try |
| catch | false | interface | static | void |
| char | final | long | strictfp | volatile |
| class | finally | native | super | while |
| const | float | new | switch | |
| continue | for | null | synchronized |
synchronized. Use volatile only for simple visibility; it does not provide atomicity.throw. Close resources with try-with-resources instead of finally blocks.public APIs small; use sealed hierarchies (when enabled) to constrain extension points; use record for pure data carriers.switch plus pattern matching often replaces long if/else ladders for clarity.