This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.