File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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