---
title: "Differences between HashMap and Hashtable?"  
description: "Differences between HashMap and Hashtable?"  
author: "Anonymous User"  
published: 2015-05-03  
updated: 2015-05-04  
canonical: https://www.mindstick.com/forum/23180/differences-between-hashmap-and-hashtable  
category: "java"  
tags: ["java", "hashtable"]  
reading_time: 1 minute  

---

# Differences between HashMap and Hashtable?

\What are the [differences](https://www.mindstick.com/articles/12918/cat-5e-vs-cat-6a-understanding-the-major-differences) between a [HashMap](https://www.mindstick.com/forum/159211/what-are-the-differences-between-a-hashmap-and-a-hashtable-in-java) and a Hashtable in [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)?\
Which is more [efficient](https://www.mindstick.com/articles/33637/three-tips-for-an-energy-efficient-home-for-2019) for non-threaded [applications](https://www.mindstick.com/articles/12847/how-to-choose-the-right-ethernet-cable-for-industrial-applications)?

## Replies

### Reply by Anonymous User

There are several differences between *HashMap* and *Hashtable* in Java:\
Hashtable is **synchronized**, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.\
Hashtable **does not allow null keys** or values. HashMap allows one null key and any number of null values.\
One of HashMap's subclasses is LinkedHashMap, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as easy if you were using Hashtable.\
Since synchronization is not an issue for you, I'd recommend HashMap. If synchronization becomes an issue, you may also look at ConcurrentHashMap.


---

Original Source: https://www.mindstick.com/forum/23180/differences-between-hashmap-and-hashtable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
