Java Reference
In-Depth Information
public Object clone()
{
try
{
MachineSimulator copy =
(MachineSimulator) super.clone();
copy.location = (Location) location.clone();
return copy;
}
catch (CloneNotSupportedException e)
{
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
Note that the return type of Object.clone() is Object , so your clone() method must
also return this type. You also have to cast the return value of the clone() method to be
the type of the field to which you assign its results.
Search WWH ::




Custom Search