Meaningless Drivel is fun!
The moose likes Java in General and the fly likes Deep Copying HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Deep Copying HashMap" Watch "Deep Copying HashMap" New topic

Deep Copying HashMap

V Bose
Ranch Hand

Joined: Jul 10, 2003
Posts: 113
If I construct a new HashMap from an existing one like

is it a deep copy of the 'original' HashMap.
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The two HashMaps will contain unique maps, but the maps reference the same objects.

Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="" target="_blank" rel="nofollow">Try my mock exam.</a>
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Intermediate forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
farhan java

Joined: Jun 05, 2006
Posts: 1
so anybody knows the solution how to copy hashmap into another hashmap with the key-value pair, without haveing same refernce.

please reply urgently.
I agree. Here's the link:
subject: Deep Copying HashMap
It's not a secret anymore!