Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashTable and HashMap

 
Venu Navat
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is difference between HashTable and HashMap ???
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HashMap is a newer class, part of the Collections framework. I would prefer it in almost all cases. Hashtable is "synchronized" but not in a way that makes me warm and fuzzy in complex multithreaded apps. I'd be more inclined to synchronize access to a private HashMap on my own or use the Collections class to generate a synchronized HashMap.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the Java API docs for the version of Java you are using. It will explain some of the differences between these two classes.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic