Object.clone

Object.clone

Class Overview | Class Members | This Package | All Packages

Syntax
protected native Object clone() throws CloneNotSupportedException
Returns
a clone of this instance.
Description
Creates a new object of the same class as this object. It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No constructor is called.

The clone method of class Object will only clone an object whose class indicates that it is willing for its instances to be cloned. A class indicates that its instances can be cloned by declaring that it implements the Cloneable interface.

Exceptions
CloneNotSupportedException if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
Exceptions
OutOfMemoryError if there is not enough memory.
See Also
Cloneable