import java.util.Hashtable;
public class DeepSheep implements Cloneable {
Hashtable flock = new Hashtable();
public Object clone() {
try {
DeepSheep copy = (DeepSheep)super.clone();
copy.flock = (Hashtable)flock.clone();
return copy;
} catch (CloneNotSupportedException e ) {
throw new Error("This should never happen!");
}
}
public void main(String [] args) {
DeepSheep one = new DeepSheep();
DeepSheep anotherOne = (DeepSheep)one.clone();
}
}
|