How can I clone an ArrayList
and also clone its items in Java?
For example I have:
ArrayList dogs = getDogs();
ArrayList
The other posters are correct: you need to iterate the list and copy into a new list.
However... If the objects in the list are immutable - you don't need to clone them. If your object has a complex object graph - they will need to be immutable as well.
The other benefit of immutability is that they are threadsafe as well.