What is the difference between HashMap and Hashtable? - ProProfs Discuss
Advertisement

What is the difference between HashMap and Hashtable?

What is the difference between HashMap and Hashtable?

Change Image    Delete

Asked by B. Wright, Last updated: Nov 24, 2024

+ Answer
Request
Question menu
Vote up Vote down

1 Answer

J. Pollock

J. Pollock

J. Pollock
J. Pollock, Science Professor, Los Angeles

Answered Aug 06, 2019

HashMap and Hashtable are two things used with Java. One of the most important things to know about HashMap and Hashtable when deciding which one to use is about their synchronization. There is no synchronization with a HashMap, and there is synchronization with a Hashtable. There is thread-safe with a Hashtable, and it is not threaded safe.

HashMap and Hashtable are two things used with Java. One of the most important things to know about
HashMap should be used when threading is not needed, and Hashtable should be used with threading. One null key is permitted with the HashMaps, and no invalid keys are allowed with Hashtables. If you need one that takes up less space but is fast, then you should use HashMap because Hashtable is slower and takes up more memory space. It is better to use unsynchronized like Hashtable because they perform better.

upvote downvote
Reply