Why do i get different behaviors with:
Collection col2 = new ArrayList(col);
Collection col2 = new ArrayList();
This code works:
public void updateCollection(Collection
But this introduces problems:
public void updateCollection(Collection
I suspect that this variation on your first method would introduce identical problems:
public void updateCollection(Collection
Why? Evidently you have another reference to objectCollection in use somewhere. Somewhere in your code, another object is saying (for instance):
myCopyOfObjectCollection = theOtherObject.objectCollection;
If you're using a getter, that doesn't change the underlying behavior - you are still keeping another reference around.
So if on initial assignment, say, the collection contained {1, 2, 3}, you start out with:
When you assign a new ArrayList to this.objectCollection, and populate it with, say, {4, 5, 6}, you get this:
"that" is still pointing to the original ArrayList.