In Java we use final keyword with variables to specify its values are not to be changed.
But I see that you can change the value in the constructor / methods of
The final keyword can be interpreted in two different ways depending on what it's used on:
Value types: For ints, doubles etc, it will ensure that the value cannot change,
Reference types: For references to objects, final ensures that the reference will never change, meaning that it will always refer to the same object. It makes no guarantees whatsoever about the values inside the object being referred to staying the same.
As such, final List ensures that foo always refers to the same list, but the contents of said list may change over time.