Sidharth Khattri wrote:But there's nothing in m2, why would it infinitely calculate the hashcode for m2?
There is one entry, added with:
m2.put(m2,1);
and the entry's key is a map, exactly that same map m2.
When you do m2.get(m2) the following things happen:
- calculation of hashCode for the key parameter (m2)
- m2 is a HashMap, its hashCode is calculated from all entries.
- one entry is m2-->1. The Entry calculates its hashCode XORing together hashCodes of key and value. But the key is a map (again m2).
- m2 is a HashMap, its hashCode is calculated from all entries.
- one entry is m2-->1. The Entry calculates its hashCode XORing together hashCodes of key and value. But the key is a map (again m2).
.......