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
JavaRanch » Java Forums » Java » Java in General
Bookmark "HashTable and HashMap " Watch "HashTable and HashMap " New topic

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.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: HashTable and HashMap
jQuery in Action, 3rd edition