Actually, you got it backwards. The value was overridden. The key wasn't replaced since as far as HashMap
is concerned, e and e2 are identical.
Your output is {1--e=e2, 2--e1=e1}
:
key = e, value = "e2" (which overrode the old value "e")
key = e1, value = "e1"