原型模式 深拷贝 重写clone方式
public class Citation implements Cloneable{ private String name; private Student student; @Override protected Object clone() throws CloneNotSupportedException { Citation clone = (Citation) super.clone(); clone.student = (Student) this.student.clone(); return clone; } }
public class Student implements Cloneable{ private String name; private int age; @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); } }