Java Records were introduced as a preview feature in JDK 14, but discussions began way earlier.
Why they're exciting:
- Reduce boilerplate for immutable data classes
- Automatically generate
equals
, hashCode
, toString
- Enforce canonical constructorExample:
public record User(String name, int age) {}
It felt very Kotlin-esque. This small change has big ergonomic wins for DTO-heavy codebases.