Results 1 to 2 of 2
- 04-11-2012, 12:02 AM #1
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 10
- 04-11-2012, 01:42 AM #2
Re: Copy Constructor with Shallow Copy
A shallow copy merely copies the reference to data, whereas a deep copy duplicates the data itself.
A related term is the lazy copy, which takes advantage of the speed of the shallow copy when at all possible, and becomes a deep copy when necessary.
If you change the value of a shallow copied object, both will reflect the change; not so with a deep copy, which are independent.
All objects have a clone() method which returns a deep copy of the object, apparently.
Similar Threads
-
Collections copy constructors guaranteed shallow?
By kjkrum in forum Advanced JavaReplies: 3Last Post: 01-23-2012, 08:34 AM -
What is the point of a copy constructor?
By ozzyman in forum New To JavaReplies: 3Last Post: 01-05-2012, 11:59 AM -
array copy in class constructor.
By Juukamen in forum New To JavaReplies: 2Last Post: 10-29-2011, 01:07 AM -
copy constructor
By shadow7 in forum New To JavaReplies: 6Last Post: 12-29-2009, 07:56 PM -
Shallow Copy Test
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 12:04 AM
Bookmarks