If I have the following statement within a class where Synapse
is an abstract type:
private final List<Synapse> synapses;
Does final
allow me to still be able to change the state of the Synapse
objects in the List
, but prevent me from adding new Synapse
objects to the list? If I am wrong, could you please explain what final
is doing and when I should be using the keyword final
instead.
unmodifiableList
constructed like this, the elements of the list can still have their state changed (if they are mutable). Nothing about the list declaration or construction can prevent that. – Friedrick