Record in Java (A to X) || Java for All || SLDC PRO

Publié le: 28 janvier 2024
sur la chaîne: SDLC PRO
302
23

Covered in this lecture:
Record is a restricted form of a class. It’s ideal for "plain data carriers" with immutable manner and minimal code.

It is introduce as a preview feature in Java 14 and finalized in Java 16
How to declare a record?
Declare 1 get 5
Compiled version of a record
Fields of a record.
1. Private final field for each of it's components
2. Can't declare non-static fields
3. Possible to declare static fields

Methods of a record
1. Public read accessor method for each component with the same name and type of the component
2. Implementations of the equals(), hashCode() and toString() methods.

Constructures of a record
1. Public constructor whose signature is derived from the record components list. It is called canonical constructor.
2. We can define canonical constructor explicitly.
3. We can define compact constructor, it is a short version of canonical constructor.
4. We can define more constructure but that should deligate to canonical constructor explicitly.

Static and Non-static block
Record VS Inheritance
Record VS Class in serialization
Set[Record] VS Set[Class] (set of record vs set of class)


Sur cette page du site, vous pouvez voir la vidéo en ligne Record in Java (A to X) || Java for All || SLDC PRO durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur SDLC PRO 28 janvier 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 302 fois et il a aimé 23 téléspectateurs. Bon visionnage!