File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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: 15101

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 8 API documentation
I agree. Here's the link:
subject: HashMap - Hashtable
It's not a secret anymore!