I googled around for the differences between these and most of the websites stated the following -
"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. "
I am unable to understand the second difference (that the hashmap iterator is failsafe). The hashmap doesnt have a iterator in the first place and the only way to get a iterator would be something like Iterator<Map.Entry<
String, Integer>> it = g.entrySet().iterator(); Does that mean that while accessing the iterator i cannot add elements to the hashmap ? because I tried that and the program worked without giving me an error. Can anyone explain what the second difference actually means? Also does the second difference pose a benefit since hashtable is synchronized and the only possible way in which the contents can be modified in a different
thread is if that thread can obtain a lock on the object.