HashMap and HashTable both implements Map interface but their are some difference between HashMap and HashTable.

1. HashMap is not synchronized whereas HashTable is synchronized.
2. HashMap allows one null key and any number of null values but HashTable does not allow null keys or values.
3. Iterator in HashMap is fail fast but Enumeration in HashTable is not fail fast.

ParameterHashmapHashtable
SynchronizedNot SyncronizedSyncronized
Null key and ValueAllows one null key and any number of null valuesNot allow null keys or values
Fail fastIterator in Hashmap is fail fastEnumeration in Hashtable is not fail fast
ThreadSafeNoYes
ExtendsExtends AbstractMap classExtends Dictionary class
PerformanceFaster then HashtableSlower then Hashmap

Note → You can synchonized a HashMap with the help of Collections.synchonizedMap(hashmap)

Map map=Collections.synchonizedMap(hashmap)

Syncronized →Being synchronized means that operation is thread safe, so only one thread can access the table at a time.

Fail safe → Fail-fast means when you try to modify the content when you are iterating, it will throw ConcurrentModification Exception and fail immediately.

For HashMap Itration:

Set keys = hashMap.keySet();
for (Object key : key) {
    hashMap.put(someObject, someValue); //it will throw the ConcurrentModificationException
}

For HashTable Enumeration:

 Enumeration keys = hashTable.keys();
 for (Enumeration e = v.elements() ; e.hasMoreElements() ; e.nextElement()) {
      hashTable.put(someKey, someValue); //it works
 }