Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What are the differences between HashMap and Hashtable?

differences hashmap hashtable
0
Posted

What are the differences between HashMap and Hashtable?

0

Location: http://www.jguru.com/faq/view.jsp?EID=430247 Created: May 29, 2001 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by elango maragtham (http://www.jguru.com/guru/viewbio.jsp?EID=248437 Both provide key-value access to data. The Hashtable is one of the original collection classes in Java. HashMap is part of the new Collections Framework, added with Java 2, v1.2. The key difference between the two is that access to the Hashtable is synchronized on the table while access to the HashMap isn’t. You can add it, but it isn’t there by default. Another difference is that iterator in the HashMap is fail-safe while the enumerator for the Hashtable isn’t. If you change the map while iterating, you’ll know. And, a third difference is that HashMap permits null values in it, while Hashtable doesn’t. For new code, I would tend to always use HashMap.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123