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
ArrayList
clone()
Use clone(), or use the copy-constructor.
The copy-constructor makes additional transformation from the passed collection to array, while the clone() method uses the internal array directly.
Have in mind that clone() returns Object, so you will have to cast to List.
Object
List