i was expecting this code to return 1 as i overrode equals. but it returned 2?
why is that?
The hashing collections require that you to obey the equal() / hashCode() contract. If you override equals, then you should also override hashCode() as well -- as you have the code written, you broke the contract.