Monday 17 June 2013

What is the difference between Hashtable and Hashmap in Java Collections ?

What is the difference between Hashtable and Hashmap in Java ?

     • Hashmap allows the null values to be both of its keys and the values, while the hashtable do not allow the null values in data structuring.
    • The hashmap cannot have the duplicate keys in it that is why there keys must only be mapped with only the single value. But the hashtable allows the duplicate keys in it.
   • The hashmap contains an iterator which is basically fail-safe but the hashtable contains an enumerator, which is not fail-safe.
  • The access to hashtable is synchronized on the table while the access to the hashmap is not synchronized.

No comments:

Post a Comment