The Depths of Immutable Class Design — 2
Why the fields should be marked as final
In the previous article, we have looked at the rules like preventing the subclass, taking care of getters returning the references to non-immutable objects, etc. In this article, we will look at the most important rule — Making the fields final and the reasons behind it.
While designing the immutable classes we need to ensure that at all costs the state will not be changed once the object is published.