Which advantages/disadvantages of making ArrayList (or other Collection) final? And what if we try to do so like:
final List<Integer> A=new ArrayList<Integer>(1,2,3,4,5);
List<Integer> l=new ArrayList<Integer>(4,8,16);
A=l;
Is this is valid? Now the reference A will point to this Array list pointed by l? Please help.
finalaffects the variable, and not the object to which is refers. 2) It is not not allowed to re-assign to afinalvariable. The compiler should have said as much.ArrayListdoes not have a constructor that will allow that usage.