If LinkedHashMap’s time complexity is same as HashMap’s complexity why do we need HashMap? What are all the extra overhead LinkedHashMap has when compared to HashMap in Java?
If LinkedHashMap’s time complexity is same as HashMap’s complexity why do we need HashMap?
Share
LinkedHashMap will take more memory. Each entry in a normal
HashMapjust has the key and the value. EachLinkedHashMapentry has those references and references to the next and previous entries. There’s also a little bit more housekeeping to do, although that’s usually irrelevant.