Note

Because procedure calls introduce necessary aliases, and because compilers are typically large programs with many procedure calls, some compiler engineers make the design choice to use immutable data structures.

Here, the goal is to make things easier to reason about and to introduce less bugs.

Warning

You can modify mutable data structures in unexpected places using aliases and such which is why mutable things are bad.

In Java, appending on an immutable object return a new data structure.

The keyword final prevent reassignment which makes something immutable as well (needs to be set on an instance in the constructor). Use this for fields.