Declaring a List field with the final keyword
No, the final keyword does not make the list, or its contents immutable. If you want an immutable List, you should use:
List<Synapse> unmodifiableList = Collections.unmodifiableList(synapses);
What the final keyword does is prevent you from assigning a new value to the 'synapses' variable. I.e., you cannot write:
final List<Synapse> synapses = createList();
synapses = createNewList();
You can, however, write:
List<Synapse> synapses = createList();
synapses = createNewList();
In essense, you can still change, add and remove the contents of the list, but cannot create a new list assigned to the variable synapses.
final
prevents you from reassigning synapses
after you've assigned it once - you can still add/remove elements as you would normally. You can read more about the final
keyword here.