This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Hash Map question ... 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Hash Map question ..." Watch "Hash Map question ..." New topic

Hash Map question ...

Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
I have a question relating to the uniqueness of keys in HashMap. I wrote this program and apparently the HashMap seems to be accepting duplicate keys. Could some one please point out what I am doing wrong or if I am missing something?

Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
Are you sure your equals method should contain "(o instanceof MyType)", not "(o instanceof MyMapKeyType)" ?
Mapraputa Is, aka hashMap
Brian Lugo
Ranch Hand

Joined: Nov 10, 2000
Posts: 165
Thanks Mapraputa !
Yep that was it. How foolish of me ...
Why does'nt the compiler correct my foolish mistakes ? No - Just kidding ...
I agree. Here's the link:
subject: Hash Map question ...
It's not a secret anymore!