How can I clone ArrayList but also clone its items in Java 1.5? For example I have: And I would expect that objects in clonedList are not the same as in dogs list. Thanks for any answer! | ||||
You will need to iterate on the items, and clone them one by one, putting the clones in your result array as you go. For that to work, obviously, you will have to get your Dog object to implement the Cloneable interface, and the clone() method. |
No comments:
Post a Comment