This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello, I got a class named test, and I override both equal and hash code in order to use test objects in hash data structures such as HashSet.
But it seems that both overridings are not working because I'm able to put 2 equals test objects in a HashSet. How can that be?
I have reviewed my code several time just to see if I missing something about the way this overridings are supposed to be written. But I do not see any mistake. I even compare the two test instance to see if the return true from the equal comparison, and also they return the same hash code. So the rule that says that if two objects are equals their hashcode must be equal is accomplished.
Here is my code. Does any body see a mistake?