File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Hash Map question ... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Hash Map question ..." Watch "Hash Map question ..." New topic
Author

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?

Thanks,
Brian
Mapraputa Is
Leverager of our synergies
Sheriff

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 ...
Brian
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hash Map question ...
 
Similar Threads
HashMap question
what It means if you don't override equals()
Accessing HashMaps
Overriding equals() and hashCode()
Problem in Creating HashMap object then display in sorted and unsorted order