
What are Java Records?
Java records were introduced as a preview feature in Java 14 (JEP 359) and finally released as a permanent feature in Java 16 (JEP 395).
A record is a special type of class designed to hold immutable data.
public record Product(String name, double price) {}
Here, a single line of code will help with private final fields, a constructor that takes all the fields, getter methods, and auto-generated toString(), equals(), and hashCode() methods.
English







