I need a shallow copy of an java ArrayList, should I use clone() or iterate over original list and copy elements in to new arrayList, which is fast
the question says shallowcopy not deepcopy.Copying directly reference from one arraylist reference to another will also work right.Deep copy includes copy individual element in arraylist.
ArrayList list=new ArrayList();
list.add(3);
ArrayList list1=list; //shallow copy...
Is there any problem in this ??