• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HashMap - Hashtable

 
sr shashidhar
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic