I have a HashMap<Vertex, Integer>
called vertexIndexes
. If I iterate through it with this code:
public boolean search(String vertexName){
for (Vertex name: vertexIndexes.keySet()){
String key = name.toString();
String value = vertexIndexes.get(name).toString();
System.out.println(key + " " + value + " "+ (name.hashCode() == vertexName.hashCode()) + " " + name.equals(vertexName));
}
...
}
it produces this output:
Diessen 0 false false
Herrsching 5 false false
Schondorf 2 false false
Greifenberg 3 false false
Stegen 4 false false
Utting 1 false false
Andechs 6 false false
Fischen 7 true true
So you can see, that the Vertex Fischen
is present and the hashCode
and equals
methods work fine. But if I run
vertexIndexes.containsKey("Fischen")
it returns false
.
Why is that? I lose my mind over it.