Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes difference between deep and shallow copy with respect to clone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between deep and shallow copy with respect to clone" Watch "difference between deep and shallow copy with respect to clone" New topic
Author

difference between deep and shallow copy with respect to clone

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
Hi,

I read deep copy does not make copies of referenced objects but only duplicated instance variables. I have not exactly understood the difference, usage, advantages of using each one of them. Any ideas, suggestions, links, sample code, resources highly appreciated. Thanks in advance
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18759
    
  40

gudim gudi wrote:
I read deep copy does not make copies of referenced objects but only duplicated instance variables. I have not exactly understood the difference, usage, advantages of using each one of them. Any ideas, suggestions, links, sample code, resources highly appreciated. Thanks in advance


I think you got it backwards. Shallow copy only copies the references, but references the same objects. A deep copy makes copies of the objects too.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: difference between deep and shallow copy with respect to clone