One Pager Cheat Sheet
- We must start by understanding
Objects, which are pieces of data that have unique identities, states, and behaviors, to properly discuss the difference betweenmutableandimmutableobjects. - An immutable object's states and behaviors cannot be changed once it is created, while a mutable object's states and behaviors can be changed after its creation.
- Instances of immutable classes are unchangeable once they are created due to their restricted access and lack of
setmethods. - The constructor has an unassigned
finalvariable and theprintModel()method should bepublicand return themodelString. - We have to clone the immutable object, and modify it, as there is no way to directly manipulate it.
- Immutable objects are useful for concurrent programming, mapping, and critical systems, providing consistency and safety.
- Java provides
default immutable classes, such asString,Boolean, andInteger, which are useful for ensuring that their values remain unaltered in complex programming scenarios. - Both
Reduxand mutable objects offer benefits and are used for different purposes, with Redux leveraging the concept of immutability to manage state and mutable objects allowing changes to be made without having to create a new copy. - The class
myClassis immutable - its values are set during its initialization and cannot be modified afterwards.


