File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes HashMap - Hashtable 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 "HashMap - Hashtable" Watch "HashMap - Hashtable" New topic
Author

HashMap - Hashtable

sr shashidhar
Greenhorn

Joined: Jan 17, 2013
Posts: 27
Hi frndz,

HashMap permits null values and null key,

HashTable doesn't allow key or value as null... why...?

Thanks in advance
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

Because that's just how those classes were designed. There's really no special reason.

You should always use HashMap and not Hashtable. Hashtable is a legacy collection class, which has more or less been replaced by HashMap since Java 1.2 (when the Collections Framework was added to Java).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HashMap - Hashtable