I understand that it is a good practice to use final
for object fields that are 1) set only once in the constructor 2) reference to an immutable object.
What about fields that are set only once in the constructor but reference to a mutable object?
Currently, I prefer using final
only for immutable object references, because I can quickly see which fields represent the mutable state of the object (those that are not final).
Update: I know how final works technically, specifically that setting a reference to a mutable object as final won't make the object immutable. This question is about when exactly use final if I want to maximize clarity and understandability of the code.