aspose file tools*
The moose likes Java in General and the fly likes Cloning in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cloning in Java" Watch "Cloning in Java" New topic
Author

Cloning in Java

Anand Jain
Greenhorn

Joined: Jul 27, 2009
Posts: 18
I was reading why do we need to clone an object and this is what I got
We clone an object when initializing an object is too expensive So, instead of creating a new object, we can clone an existing one and only change the properties that matter to our new instance.


I didn't get it properly.Could someone please elaborate it or explain it some other way?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3649
    
  17

Could you quote your source? It sounds pretty silly.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Anand Jain wrote:I was reading why do we need to clone an object and this is what I got
We clone an object when initializing an object is too expensive So, instead of creating a new object, we can clone an existing one and only change the properties that matter to our new instance.


This makes no sense. There's no reason to think cloning will be any faster than creating a new object the "normal" way. It sounds like the author doesn't know what he's talking about.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cloning in Java