Re: Map.get(key) returns null after inserting key
- From: ptomblin+netnews@xxxxxxxxx (Paul Tomblin)
- Date: Sun, 31 Dec 2006 03:21:32 +0000 (UTC)
In a previous article, "Mize-ze" <zahy.bnaya@xxxxxxxxx> said:
Hello,
I am inserting a key and a object into a Map. later in the code I try
to retrieve the object by calling
Map.get(key) and I get a null.
I can't see where is my problem...
I only had to read this far to guess what the problem is - you haven't
implemented hashCode on your key class, or if you have, you haven't
implemented it properly, and you're using HashMap.
I know this, because I made the same mistake (AGAIN) a few weeks ago. I
changed something from TreeSet to HashSet and things weren't working the
way I expected.
--
Paul Tomblin <ptomblin@xxxxxxxxx> http://blog.xcski.com/
It might not be practical, it might not be a good idea, but it could work.
Sort of like Windows.
-- berry
.
- References:
- Map.get(key) returns null after inserting key
- From: Mize-ze
- Map.get(key) returns null after inserting key
- Prev by Date: Looking for a starting point
- Next by Date: Re: MIDI OUT transmitter not available?
- Previous by thread: Re: Map.get(key) returns null after inserting key
- Next by thread: Parentheses issue
- Index(es):
Relevant Pages
|
Loading