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.
I have read that in maps you need to override equals when you create your own class to use it as a key. I didn't do it and still it lets me insert elements as you can see in the following code:
I don't have much experience working with collections. I have read the collection's chapter in K & B book, but still I don't feel I confident with it. Does anyone know about a book or a website where collections are explained in more detail???
it is working that way because your class ToDos inherit equals() method from Object class. But in that way once you lose the reference(address) to the object, used as a key, you can't retreive that object because equals() method compares the bitpattern of the variables
Joined: Sep 18, 2009
Thank you very much, I understand it now. So the default equals from Obejct compares the references, but what about Object's hashcode, what's its behaviour?