How can I clone an ArrayList and also clone its items in Java?
ArrayList
For example I have:
ArrayList dogs = getDogs(); ArrayList
Here is a solution using a generic template type:
public static List copyList(List source) { List dest = new ArrayList(); for (T item : source) { dest.add(item); } return dest; }