I have an ArrayList
that contains objects. (this objects are clases, every object contains an incredibly large amount of information, precisely these object represent large electric generators, so copying the properties one by one is not an option).
example:
ArrayList arr = {ob1, ob2, ob3, ob4, ob5}
So what I try to do is to clone the object (ob1) to the position 5.
arr.set(4, arr.get(0));
But somehow, doing that, ob5 is not a copy ob ob1, it is ob1, so if I change ob5, ob1 changes too.
Is this something inherent to ArrayLists? Is there any difference if I use Lists instead?