A record declaration specifies a new record class, a restricted kind of class that defines a simple aggregate of values.
RecordDeclaration:
{ClassModifier} record TypeIdentifier [TypeParameters] RecordHeader [ClassImplements] RecordBody
A record declaration may specify a top level record class (§7.6), a member record class (§8.5, §9.5), or a local record class (§14.3).
The TypeIdentifier in a record declaration specifies the name of the record class.
It is a compile-time error if a record declaration has the modifier abstract, sealed, or non-sealed.
A record class is implicitly final. It is permitted for the declaration of a record class to redundantly specify the final modifier.
A nested record class is implicitly static. That is, every member record class and local record class is static. It is permitted for the declaration of a member record class to redundantly specify the static modifier, but it is not permitted for the declaration of a local record class (§14.3).
It is a compile-time error if the same keyword appears more than once as a modifier for a record declaration, or if a record declaration has more than one of the access modifiers public, protected, and private (§6.6).
The direct superclass type of a record class is Record (§8.1.4).
A record declaration does not have an extends clause, so it is not possible to explicitly declare a direct superclass type, even Record.
The serialization mechanism treats instances of a record class differently than ordinary serializable or externalizable objects. In particular, a record object is deserialized using the canonical constructor (§8.10.4).
Sections: