Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashTable and HashMap  RSS feed

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell me the difference between hashtable and hashmap and when to use them?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hashtable is synchronized.
You will probably use HashMap most of the time.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, Hashtable does not allow the keys or values to be null, while HashMap does.

Hashtable is one of the old legacy collection classes from Java 1.1. You should use HashMap as much as possible instead.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really an advanced question. Moving...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!