Records are a new language feature since Java 14 (first preview) and Java 15 (second preview). As per my understanding they will be used to reduce boilerplate code in immutable data objects.
So this sigle line:
public record Person (String firstName, String lastName) {}
Is equivalent to declaring a class with private final fields, getter for each field, a public constructor and equals, hashCode and toString methods.
However this is pretty much the same as using lombok @Value
annotation:
@Value
public class Person {
String firstName;
String lastName;
}
Other than you obviously doesn't need to deal with the lombok dependency, is there any advantange of using records?