โ Module import declarations
Import all exported packages of a module with a single declaration.
Many Imports โ import module (JDK 25+)
๐ https://t.co/WMHkuFLsi6
#Java#JavaEvolved
โ Pattern matching for instanceof
Combine type check and cast in one step with pattern matching.
instanceof + Cast โ Pattern Variable (JDK 16+)
๐ https://t.co/0lVOGbVf8I
#Java#JavaEvolved
โ Writing files
Write a String to a file with one line.
FileWriter + BufferedWriter โ Files.writeString() (JDK 11+)
๐ https://t.co/IFRm5dEphH
#Java#JavaEvolved
โ Strong random generation
Get the platform's strongest SecureRandom implementation.
new SecureRandom() โ getInstanceStrong() (JDK 9+)
๐ https://t.co/yZeCiSUxLp
#Java#JavaEvolved
โ Unnamed variables with _
Use _ to signal intent when a variable is intentionally unused.
Unused Variable โ _ Placeholder (JDK 22+)
๐ https://t.co/EkEQrKLstk
#Java#JavaEvolved
โ Optional.ifPresentOrElse()
Handle both present and empty cases of Optional in one call.
if/else on Optional โ ifPresentOrElse() (JDK 9+)
๐ https://t.co/Xg6M4ppHxo
#Java#JavaEvolved
โ Math.clamp()
Clamp a value between bounds with a single clear call.
Nested min/max โ Math.clamp() (JDK 21+)
๐ https://t.co/LjLrZKb3e4
#Java#JavaEvolved
โ Guarded patterns with when
Add conditions to pattern cases using when guards.
Nested if โ when Clause (JDK 21+)
๐ https://t.co/Km3M4tpLi4
#Java#JavaEvolved