wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Shallow & Deep Objects 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 "Shallow & Deep Objects" Watch "Shallow & Deep Objects" New topic
Author

Shallow & Deep Objects

Tom Keith
Greenhorn

Joined: Mar 26, 2002
Posts: 24
Hi All,
Few of my friends were using the terms Shallow & Deep Objects. Can somebody tell what it means? Is it something new or just a differnt name for some concept?
Thanks,
Tom
[ April 16, 2002: Message edited by: Tom Keith ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Perhaps you mean a shallow vs a deep copy or clone?
If you clone something - say an array, there are two ways that you can do it. You can create an identical array where each of the elements of the arrays point to the same objects. This is a shallow copy.
array1 = [ obj1 ] [ obj2 ] [ obj3 ] copies to
array2 = [ obj1 ] [ obj2 ] [ obj3 ]
Both array1 and array2 have elements referencing the SAME objects.
In a deep clone not only do you create a new array object, you also create copies of each of the objects that are referenced by the array.
array1 = [ obj1 ] [ obj2 ] [ obj3 ] copies to
array2 = [ CopyOfObj1 ] [ CopyOfObj2 ] [ CopyOfObj3 ]
This is a deep copy.
Is this what you are talking about?
[ April 16, 2002: Message edited by: Cindy Glass ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
 
Consider Paul's rocket mass heater.
 
subject: Shallow & Deep Objects
 
Similar Threads
Deep and Shallow Comparison!!
clone() method
shallow cloning and deep cloning
shallow cloning and deep cloning
about clone