Why even if the declared final list of arrays can be expanded with new elements
3 answers
final
means that this link list
is, final
that can not be changed. As you cannot assign any other list
or reinitialize this one list
.
final List<String> items = new ArrayList<>();
items = otherStringList;//ERROR
items = new ArrayList<>();//ERROR
JLS(Β§4.12.4)
is talking,If the final variable contains a reference to an object, then the state of the object can be changed using operations on the object , but the variable will always refer to the same object.
+2
source to share