Take the 2-minute tour ×  Today I was asked this question during
an interview:  What's gonna happen if we do not override
hashcode method for our class, then add it to HashTable and then
try to get objects?  Could you help me answer that?
share|improve this question Read this book if you want to get a
job programming java. –  Martin Schröder Apr 17 '12 at 6:48
@MartinSchröder I have a job already) –  VextoR Apr 25 '12 at
7:22 add comment  8 Answers  up vote 18 down vote accepted  The
idea with a HashTable when you try retrieving an object is that
the data structure computes the hash code of the object using
the GetHashCode() method and then goes through a list using the
Equals() method.  With default GetHashCode() implementation, two
perfectly similar objects might end up yielding different hash
codes which means that if you do not use the exact same
instance, you will never find the your object in the HashTable.
In general, you want to make sure of two things when
implementing hash codes:    • If A.Equals(