Enumerating over Map#entrySet doesn\'t work as expected for all Map implementations, specially for EnumMap, IdentityHashMap and here is the sample code
EnumMap.EntryIterator.next() returns this reference. You can verify it as follows:
Iterator extends Map.Entry> e = map.entrySet().iterator();
while (e.hasNext()) {
Map.Entry x = e.next();
System.out.println(System.identityHashCode(x));
}