How to clone a Java object with the clone() method

后端 未结 8 1261
孤街浪徒
孤街浪徒 2020-12-20 11:29

I don\'t understand the mechanism of cloning custom object. For example:

public class Main{

    public static void main(String [] args) {

        Person pe         


        
8条回答
  •  佛祖请我去吃肉
    2020-12-20 12:21

    There's no need to create the object explicitly here in clone() method. Just by calling super.clone() will create the copy of this object. It will perform the shallow clone.

提交回复
热议问题