How to clone ArrayList and also clone its contents?

后端 未结 21 1924
小鲜肉
小鲜肉 2020-11-21 06:42

How can I clone an ArrayList and also clone its items in Java?

For example I have:

ArrayList dogs = getDogs();
ArrayList

        
21条回答
  •  伪装坚强ぢ
    2020-11-21 07:16

    I have used this option always:

    ArrayList clonedList = new ArrayList(name_of_arraylist_that_you_need_to_Clone);
    

提交回复
热议问题