This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes difference between hashmap&hashtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between hashmap&hashtable" Watch "difference between hashmap&hashtable" New topic
Author

difference between hashmap&hashtable

Ksam kumar
Greenhorn

Joined: Jul 13, 2007
Posts: 1
i want detail above question.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Hashtable has his methods synchronized and Hashtable doesn't allow Null-values and a Null-key.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
 
 
subject: difference between hashmap&hashtable