Also, what class are your keys? Does this class override equals() and hashCode()? Both these methods are used by a HashMap, and if there are any bugs in the implementation of these methods, they can cause strange behavior of the Map. If the class of your keys is one of the standard
Java library classes (e.g. a
String or Integer, to take two particularly common examples) then there's probably no problem, but if it's a class someone has created themselves, you might want to study the equals() and hashCode() methods to make sure they work correctly.