This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Clone() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Clone() method" Watch "Clone() method" New topic
Author

Clone() method

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
Hi,

I read cloneable interface is tagging interface. Class must override Clone() metjod declaring it as public where as Clone() method declared as protected in Object class. Any ideas, suggestions, links, resources, sample code highly appreciated. Thanks in advance
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3983
    
  18

Well, you should ask more specific questions. Is there anything you don't understand?

The clone() method is very tricky. It's useful to know how it works, but you shouldn't be eager to put it to use. It breaks easily.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43905
    
  33
Effective Java™ by Joshua Bloch, page 54.
You may be able to find a sample chapter from the first edition free of charge on the net; that covers clone().
 
Have you checked out Aspose?
 
subject: Clone() method
 
It's not a secret anymore!