A record gives a data aggregate named components and generated accessors. It also supplies equality, a hash code and a string representation based on those components. Use records when those component values describe the identity of the value you want to model. A booking key with room and day must compare both.
A compact constructor can normalize or validate the incoming parameters before Java assigns them to the final component fields. Construction either creates a valid value or throws; don't count a record as accepted before construction succeeds. Records don't make mutable component objects deeply immutable. An array component is still an array, and its generated equality uses the component's equality behavior. The later snapshot lesson handles defensive copies explicitly.