my dog learned polymorphism*
The moose likes Java in General and the fly likes HashTable and HashMap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HashTable and HashMap " Watch "HashTable and HashMap " New topic
Author

HashTable and HashMap

Venu Navat
Ranch Hand

Joined: Dec 28, 2004
Posts: 30
what is difference between HashTable and HashMap ???


-Venu Navat
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HashTable and HashMap