Records automatically provide common methods like equals(), hashCode(), and toString().
Java records are a special kind of class designed to hold immutable data. They automatically generate implementations of common methods such as equals(), hashCode(), and toString(), reducing the need for boilerplate code. This is useful in domain models where the focus is on the data being represented rather than behavior. For example, using a record to represent a simple data structure like a Point with x and y coordinates can save a lot of code.
Additional Notes
Why are Java records significant for reducing boilerplate code?