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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "HashMap - Hashtable" Watch "HashMap - Hashtable" New topic

HashMap - Hashtable

sr shashidhar

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

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
Similar Threads
Hashtable vs. HashMap
advantage of hashmap over hashtable
hashmap with null values and keys
HashMap Vs Hash table
EXCEPT SYNCHRONIZATION what are the main diff between ArrayList and Vector