• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between deep and shallow copy with respect to clone

 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21016
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic