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

Veröffentlicht am: 28 Januar 2024
auf dem Kanal: 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)


Auf dieser Seite können Sie das Online-Video Record in Java (A to X) || Java for All || SLDC PRO mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer SDLC PRO 28 Januar 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 302 Mal angesehen und es wurde von 23 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!