How to clone ArrayList and also clone its contents?

后端 未结 21 1909
小鲜肉
小鲜肉 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:10

    The package import org.apache.commons.lang.SerializationUtils;

    There is a method SerializationUtils.clone(Object);

    Example

    this.myObjectCloned = SerializationUtils.clone(this.object);
    

提交回复
热议问题