Java中实现对象clone的方式是implements Cloneable interface,然后在实现类中重写Object clone()方法.在Java中默认的是"shallow copy", 所以如果类的attribute中含有对象,并且希望实现"deep copy",就要将所涉及的类都 implements Cloneable
and Serializable interfaces, 然后使用对象序列化的方式将对象写入disk, 然后再从disk中读出,并返回.
In java, There are two different ways that can be used to copy an object:
shallow copy and
deep copy
What is shallow copy in java
A shallow copy would copy the ......
阅读全文