This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Cloning a Hashtable 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 » Java in General
Bookmark "Cloning a Hashtable" Watch "Cloning a Hashtable" New topic
Author

Cloning a Hashtable

bhuvan gupta
Greenhorn

Joined: Mar 26, 2001
Posts: 13

the java documentation says :
Hashtable.clone() Creates a shallow copy of this hashtable. The keys and values themselves are not cloned. This is a relatively expensive operation.
What do u mean by shallow copy ?? Is it just means creating a new reference of the object or something more ??
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
A shallow copy in this case is a new hashtable, with one entry for each entry in the original hashtable, but the entries refer to the same keys and values as the original hashtable.
for example, consider this sequence:


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
bhuvan gupta
Greenhorn

Joined: Mar 26, 2001
Posts: 13
Got the funda
Thank you very much Frank
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cloning a Hashtable
 
Similar Threads
Question about clone a Hashtable
Cloneable interface!!
shallow copy vs deep copy?
shallow copy and deep copy
need your help about a cast about cloneable.!!!(jcjp07-Q119)