ich iterieren eine HashMap mit dieser Methode:get von HashMap null wird während itteration
public void printMap(Map mp) {
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
System.out.println(pair.getKey() + " = " + pair.getValue() + " " + mp.get("objectId"));
}
it.remove(); // avoids a ConcurrentModificationException
}
Das Ergebnis ist:
Key1 = Value1 objectIDValue
Key2 = Value2 objectIDValue
objectId = objectIDValue objectIDValue
Key4 = Value4 null
Key5 = Value5 null
...
Warum mp.get ist ("objectId") wird null, wenn die Schlüssel ist bestanden?