Before I discuss records and why they are needed, let me articulate the concept of immutability. Immutability is a key aspect of clean and safe programming. An immutable object is one whose state cannot be changed once instantiated, where the state is the data contained in the object instance. When an object's state is set, it stays the same throughout its lifetime. In Java, for example, immutable objects do not have any setter methods to guarantee their state never changes.
Examples of Immutable Objects
Java’s standard library is rich with immutable classes, including:
dzone.com
dzone.com
