发生此错误的原因是在对象类中clone()方法受到保护。因此,您必须在相应的类中重写clone()方法。例如。在MyClass中添加以下代码
@Overrideprotected Object clone() throws CloneNotSupportedException { return super.clone();}还实现Cloneable接口。例如。
public class MyClass implements Cloneable

发生此错误的原因是在对象类中clone()方法受到保护。因此,您必须在相应的类中重写clone()方法。例如。在MyClass中添加以下代码
@Overrideprotected Object clone() throws CloneNotSupportedException { return super.clone();}还实现Cloneable接口。例如。
public class MyClass implements Cloneable