Cloning

From Suhrid.net Wiki
Revision as of 16:11, 22 June 2012 by Suhridk (talk | contribs) (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 ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  • 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.