By default, the method is
protected because there is no universal implementation, and invoking it leads to a
CloneNotSupportedException. To use cloning, you must write your own implementation, make it
public, and add the
Cloneable interface to your class. It is implied that this method should perform a "deep copy," meaning that any reference fields in the clone should point to copies of the original's fields. This is dictated by the requirement saying that a clone should not depend on the original.
According to the contract, a clone must be a distinct object (
!= to the original). It is recommended that all classes in the hierarchy implement
Cloneable, that the method implementation begins with
super.clone() (unless the parent is
Object), and that the result
equals to and of the same class as the original.
Alternatives to the
clone method (
often considered more convenient) include the copy constructor and the factory method pattern. Everything you need to know about copying objects in Java can be found in
Effective Java Item 11.