Difference between revisions of "Cloning"

From Suhrid.net Wiki
Jump to navigationJump to search
(Created page with "* There is no syntactical way to copy an object in Java. The assignment operator just's duplicates the reference. * Cloning and the clone() method provides a way to perform such ...")
(No difference)

Revision as of 15:11, 22 June 2012

  • There is no syntactical way to copy an object in Java. The assignment operator just's duplicates the reference.
  • Cloning and the clone() method provides a way to perform such copying.
  • The object class has a clone() method which is protected. So it has to be overriden in the implementing class in order to use it.
  • The default implementation can call super.clone() - but this means the class has to implement the Cloneable marker interface.