wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 14074
    
  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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HashMap - Hashtable
 
Similar Threads
EXCEPT SYNCHRONIZATION what are the main diff between ArrayList and Vector
Hashtable vs. HashMap
advantage of hashmap over hashtable
hashmap with null values and keys
HashMap Vs Hash table