Difference between the hash map, hash table and hash set
Hash table
It didn’t allow null for both key and value. You will get NullPointerException if you add null value.
It is synchronized. So it comes with its cost. Only one thread can access in one time
Hash map
It allows null for both key and value
It is unsynchronized. So come up with better performance
Hash set
HashSet does not allow duplicate values. It provides add method rather put method. You also use its contain method to check whether the object is already available in HashSet. HashSet can be used where you want to maintain a unique list.
No comments:
Post a Comment