Friday, June 1, 2012

Good Article on how Java Hashtable Works

Article: www.javaworld.com/javaworld/javaqa/2002-06/01-qa-0621-hashtable.html

Key learnings:
  1. Objects used as keys should override hashCode() and equals() for best performance.
  2. In the implementation of hashCode(), it is not necessary for distinct objects to generate distinct hashCodes.
  3. Distinct objects with coincidentally identical hashCodes() will be placed in the same "bucket" in which sequential search using "equals" will be done.

No comments:

Post a Comment