About clone ()
被克隆的类要 implements Cloneable ,否则抛异常。
被克隆的类中最好重写clone()方法,例如:
public Book clone(){
Book book=null;
try {
book=(Book)super.clone();
} catch (CloneNotSupportedException e) {e.printStackTrace();}
return book;
}
About clone ()
被克隆的类要 implements Cloneable ,否则抛异常。
被克隆的类中最好重写clone()方法,例如:
public Book clone(){
Book book=null;
try {
book=(Book)super.clone();
} catch (CloneNotSupportedException e) {e.printStackTrace();}
return book;
}