I recently found out that there are actually 2 different ArrayList implementations in Java (better late than never I guess...).
So I was wondering why d
Two comments:
1, Attempting to shrink the returned array by calling the remove() method of List interface will throw an UnsupportedOperationException. This is because the inner ArrayList class inside of Arrays class extends AbstractList, and the remove() method in AbstractList throws UnsupportedException.
Thus once the List is returned, you can overstore existing elements EITHER in the array OR in the returned List, BUT you are NOT permitted to grow the array or shrink the array.
actually you are able to add elements to the ArrayList with add. method like this : List l2= new ArrayList(Arrays.asList(array1)); l2.add("blueCheese");
-dbednar