ac1=new ArrayCollection();
ac2=new ArrayCollection();
ac3=new ArrayCollection();
In Shallow copy both the object will refer to the same memory which contain the data.
ac2=ac1;
Both ac1 and ac2 will refer to same memory. The changes that we made to any ac1 or ac2 will reflect to each other.
After Deep copy we will have two independent object which are pointing to two memory locations containing the same data.
ac2=new ArrayCollection(ArrayUtil.toArray(ObjectUtil.copy(ac1.source)));
The above code will perform a deep copy. Now the two ArrayCollections are independent to each other.
Merge Two ArrayCollections
ac3=new ArrayCollection(ac1.toArray().concat(ac2.toArray()));
ac2=new ArrayCollection();
ac3=new ArrayCollection();
In Shallow copy both the object will refer to the same memory which contain the data.
ac2=ac1;
Both ac1 and ac2 will refer to same memory. The changes that we made to any ac1 or ac2 will reflect to each other.
After Deep copy we will have two independent object which are pointing to two memory locations containing the same data.
ac2=new ArrayCollection(ArrayUtil.toArray(ObjectUtil.copy(ac1.source)));
The above code will perform a deep copy. Now the two ArrayCollections are independent to each other.
Merge Two ArrayCollections
ac3=new ArrayCollection(ac1.toArray().concat(ac2.toArray()));
No comments:
Post a Comment