• Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap - Hashtable  RSS feed

 
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
 
Java Cowboy
Sheriff
Posts: 16082
88
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
Boost this thread!