This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between hashmap&hashtable

 
Ksam kumar
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want detail above question.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47250
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Hashtable and HashMap. Please check the spelling.

Go to the API documentation and look for Map. When you open that, it gives brief details of what a Map is; you will find both the classes you quoted are Maps.

Read the descriptions of both classes. Particularly look for handling of null values, whether any methods are synchronized, whether there are any methods returning Iterators or Enumerations, and when the classes were introduced.

Most people doing modern Java programming use HashMap and don't use Hashtable, although this is not a "rule" or "regulation."

[edit]Additional: You will find HashMap and Hashtable underlined in blue when you find Map; those are links which will lead you where you want to go. [/edit]
[ July 13, 2007: Message edited by: Campbell Ritchie ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hathtable is a legacy collection class, i.e., a legacy class from before Java version 1.2, when the Collections framework was added to Java. HashMap is more or less the replacement for Hashtable since Java 1.2.

In new programs, you should use HashMap and not Hashtable.
 
Remko Strating
Ranch Hand
Posts: 893
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hashtable has his methods synchronized and Hashtable doesn't allow Null-values and a Null-key.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic