This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cloning a Hashtable

 
bhuvan gupta
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
bhuvan gupta
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got the funda
Thank you very much Frank
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic