Which advantages/disadvantages we can get by making ArrayList (or other Collection) final? I still can add to ArrayList new elements, remove elements and update it. But what is effect making it’s final?
Which advantages/disadvantages we can get by making ArrayList (or other Collection) final? I still
Share
This means that you cannot rebind the variable to point to a different collection instance:
As a matter of style, I declare most references that I don’t intend to change as
final.If you wish, you can prevent insertion, removal etc by using
Collections.unmodifiableList():