This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes clone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "clone" Watch "clone" New topic
Author

clone

Rakesh Sharma
Ranch Hand

Joined: Dec 29, 2000
Posts: 37
what are clone objects and how it is useful?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Clone is not an object, it is a method for copying an object. Normally if you have a variable and it is "equal" to an object then the variable holds a reference to the location of the object.
Circle c1 = new Circle();
Circle c2 = new Circle();
c1 = c2;
Now you have 2 circles both containing the reference to a single object.
If you actually want to create a deep copy of the object (not just a copy of the reference), then you need to clone it.
c1 = c2.clone();
Now you have two object that are exactly ALIKE.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clone
 
Similar Threads
WA #1.....word association
clone( )
Prototype Pattern
Polling Database Tables
clone