Posts

Showing posts with the label hashset

What is the difference between hashmap, hashtable and hashset

Hashmap: Hash table implements Map interface Hash table permits null values and the null key HashMap class is equivalent to Hashtable, except that it is unsynchronized and permits nulls It does not guarantee that the order will remain constant over time constant-time performance for the operations (get, put and remove)   Time complexity - O(1) for  get, put and remove                 (Learn About capacity  ,  load factor  and  fail-fast ) It is not synchronized How to make Hashmap Synchronize                  Map m = Collections.synchronizedMap(new HashMap(...)); Exapmle :                    import java.util.*;                    public class HashMapEx{