Java 17¶
Java 17 (2021) - LTS:
-
Sealed Classes (standard): The preview feature from Java 15 became standard.
-
Pattern Matching for switch (preview): Extended pattern matching to switch statements and expressions.
String formatted = switch (obj) {
case Integer i -> String.format("int %d", i);
case Long l -> String.format("long %d", l);
case Double d -> String.format("double %f", d);
case String s -> String.format("String %s", s);
default -> obj.toString();
};
- Strong encapsulation of JDK internals: Further restricted access to internal APIs.