super.object1.clone();
na obiekcie super powinieneś wywołać metodę klasy rodzica. więc twój zapis jest niepoprawny
Dla szerszego przykładu
public Object clone() throws
CloneNotSupportedException
{
// Assign the shallow copy to new reference variable t
Test2 t = (Test2)super.clone();
t.c = new Test();
// Create a new object for the field c
// and assign it to shallow copy obtained,
// to make it a deep copy
return t;
}
dokumentacja
dokumentacja
protected Object clone()
throws CloneNotSupportedException
Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:
x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()