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.
Hashing is more of an algorithm than the Java implementation. So if you want to know "why" something is, it may be better to pick up a book on algorithms, than look at the JavaDocs... All the JavaDocs will do is give you the contracts, not the explanations.
but my doubt is y reverse is not true
Reverse of what is not true? Please clarify the question.
Akash..in collections..let say in Sets. Duplicates are not allowed. For better performance, set first uses hashcode to determine if a similar object is already in the Set.
If hashcode differs it will directly put it inside the Set...so even if objects are meaningfully equal its putting them..and creating a duplicate element.
But the reverse is not true i.e two different objects can have the same hashcode. If a Set gets the same hashcode(hashcode is just the bucket-id)..it wont directly discard the object as duplicate. It will go to the appropriate bucket depending on hashcode and compare the objects using equals() method.
If you practice with them for a while..u will surely get it.