Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between hashmap&hashtable

 
Ksam kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want detail above question.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • 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
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic