实现clone要有两个条件:
1. 覆盖clone()方法
2. 实现Cloneable接口
例子
package test;
public class User implements Cloneable{
public int i = 1;
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
实现clone要有两个条件:
1. 覆盖clone()方法
2. 实现Cloneable接口
例子
package test;
public class User implements Cloneable{
public int i = 1;
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
}