☕ 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