Object immutability
Let’s continue learning how to minimize object creation to increase the performance of our Java applications. Object immutability refers to an object that cannot be modified once it has been instantiated. Immutability can be considered a property or characteristic of an object. The advantages of making objects immutable include system predictability and performance.
Let’s start with a brief overview of object immutability.
Immutability overview
Object immutability is not a new concept, but it is an important one. The general premise is that we create an object with all the desired attributes and behaviors, and then prevent it from being mutated (changed) throughout the object’s life cycle.
Immutable objects and considered safe because they cannot be changed. This means that we can share these objects in multi-threaded environments without the requirement for synchronization. So, concurrent programming is simplified. You will learn...