How can I clone an ArrayList and also clone its items in Java?
ArrayList
For example I have:
ArrayList dogs = getDogs(); ArrayList
I think I found a really easy way to make a deep copy ArrayList. Assuming you want to copy a String ArrayList arrayA.
ArrayListarrayB = new ArrayList(); arrayB.addAll(arrayA);
Let me know if it doesn't work for you.