wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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="http://www.danchisholm.net/" 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Deep Copying HashMap