How do I make a class that supports cloning?

John Mitchell

To be cloneable, your class must at least implement the Cloneable interface. If that's all you do then your class will inherit the default implementation of the clone() method from java.lang.Object (which just performs a shallow copy). If you need to do anything special to clone your object then you should override the clone() method.

For more information, check out section 20.1.5 of the Java Language Specification.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact