HashMap uses the hashCode() method, and expects it to return values "consistent with equals()". What this means is that if you override equals() for a class, you always need to override hashCode() as well, so that two objects that are equal() will have the same hashCode() return value.
In your case, an excellent implementation would just delegate to "name" -- i.e.,
Since your equals() method is also based solely on the "name" member, this will do the exactly right thing.