When come to a time you need to choose from HashMap and HashTable, here is the differences.
1. HashMap is faster in single thread environment because it is not thread safe. On the other hand HashTable is thread safe, but performs slower than HashMap in single thread environment. Therefore for technical questions sake, mostly it is wise to choose HashMap.
2. HashMap allows null values whereas HashTable does not. Therefore if want to use a HashMap to check if a key has a correspondence, it will simply return null if there is no such correspondence.
3. “The third significant difference between HashMap vs HashTable is that Iterator in the HashMap is a fail-fast iterator while the enumerator for the HashTable is not and throw ConcurrentModificationException if any other Thread modifies the map structurally by adding or removing any element except Iterator’s own remove() method. ” – quote from MANISH CHHABRA’s blog. Therefore if in the case wanting to predict iteration order, HashMap can be swapped by one of its subclass LinkedHashMap.
Basically, unless synchronization is a issue, normally HashMap is a wiser choice.