62,614
社区成员
发帖
与我相关
我的任务
分享
public Object deepClone() throws Exception
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(this);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
}
public Object clone(){
Object o = null;
try{
o = super.clone();
if (this.next != null){
((Snake)o).next = (Snake)this.next.clone();} }catch(CloneNotSupportedException e){}
return o;
}