java.lang
Interface Cloneable

All Known Subinterfaces:
AclEntry sample code for java.security.acl.AclEntry definition code for java.security.acl.AclEntry , Attribute sample code for javax.naming.directory.Attribute definition code for javax.naming.directory.Attribute , AttributedCharacterIterator sample code for java.text.AttributedCharacterIterator definition code for java.text.AttributedCharacterIterator , Attributes sample code for javax.naming.directory.Attributes definition code for javax.naming.directory.Attributes , CertPathBuilderResult sample code for java.security.cert.CertPathBuilderResult definition code for java.security.cert.CertPathBuilderResult , CertPathParameters sample code for java.security.cert.CertPathParameters definition code for java.security.cert.CertPathParameters , CertPathValidatorResult sample code for java.security.cert.CertPathValidatorResult definition code for java.security.cert.CertPathValidatorResult , CertSelector sample code for java.security.cert.CertSelector definition code for java.security.cert.CertSelector , CertStoreParameters sample code for java.security.cert.CertStoreParameters definition code for java.security.cert.CertStoreParameters , CharacterIterator sample code for java.text.CharacterIterator definition code for java.text.CharacterIterator , CRLSelector sample code for java.security.cert.CRLSelector definition code for java.security.cert.CRLSelector , Descriptor sample code for javax.management.Descriptor definition code for javax.management.Descriptor , GSSCredential sample code for org.ietf.jgss.GSSCredential definition code for org.ietf.jgss.GSSCredential , Name sample code for javax.naming.Name definition code for javax.naming.Name

public interface Cloneable

A class implements the Cloneable interface to indicate to the Object.clone() sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class.

Invoking Object's clone method on an instance that does not implement the Cloneable interface results in the exception CloneNotSupportedException being thrown.

By convention, classes that implement this interface should override Object.clone (which is protected) with a public method. See Object.clone() sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() for details on overriding this method.

Note that this interface does not contain the clone method. Therefore, it is not possible to clone an object merely by virtue of the fact that it implements this interface. Even if the clone method is invoked reflectively, there is no guarantee that it will succeed.

Since:
JDK1.0
See Also:
CloneNotSupportedException sample code for java.lang.CloneNotSupportedException definition code for java.lang.CloneNotSupportedException , Object.clone() sample code for java.lang.Object.clone() definition code for java.lang.Object.clone()