β 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