如何对一个对象进行深度复制,该对象在java中的对象内引用了它的类型
public class Employee implements Cloneable {
private String Lastname;
private String Firstname;
private Employee supervisor;
private Employee staff[];
@Override
protected Object clone() throws CloneNotSupportedException {
Employee copy = (Employee) super.clone();
copy.supervisor = (Employee)supervisor.clone();
copy.staff = staff.clone();
return copy;
}
}