aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "HashMap" Watch "HashMap" New topic
Author

HashMap

shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
If we add duplicate items in a hashmap as in
MyHashMap.put("Shree",7000);
MyHashMap.put("Shree",9000);
when i ask to print out the contents using an iterator, i see that only the last stored value is valid.
That is,
I get Shree 9000
What exactly happens out there? Is the first reference removed and the new one added?


------------------
Regards,
Shree


Regards,<BR>Shree
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Hi Shree,
this is taken from javadoc for the put() of HashMap
"If the map previously contained a mapping for this key, the old
* value is replaced."
HTH,
Brian C
shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
Thanks Brian, where do you look up for the javadoc?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
This is the API for 1.3
http://java.sun.com/j2se/1.3/docs/api/index.html
Scroll down the left to find hashmap and click on it.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashMap