implements Cloneable
Cloneable是接口,clone()要你自己写,拟利用super.clone(),可你的父类是Object。
所以你的clone()应改为:
public Object clone() {
Object o = null;
try {
o = new MyObject();
o.i = this.i;
} catch(CloneNotSupportedException e) {
System.err.println("MyObject can't clone");
}
return o;
}
Cloneable是接口,clone()要你自己写,拟利用super.clone(),可你的父类是Object。
所以你的clone()应改为:
public Object clone() {
Object o = null;
try {
o = new MyObject();
o.i = this.i;
} catch(CloneNotSupportedException e) {
System.err.println("MyObject can't clone");
}
return o;
}
by the way,Object类是有clone()方法,你写的方法好像就是没有用到克隆的概念:)不吝赐教