I am preparing for software interviews and i am stuck with a question for days now.
I have not been able to figure out the difference between linkedhashmap, map, hashtab
I doubt the differences can be explained significantly better than what's already written in the JavaDocs for these classes:
All of the aforementioned Map
implementations have their basic get/put operations in (amortized) O(1) time complexity. There are minor differences in the handling of null
values, it's inevitable to check the JavaDoc for details.
To get an idea of how these classes are implemeted, have a look at their inheritance tree:
Map
(just the interface)
Dictionary
(obsoleted abstract class)
Hashtable
(the "old" map implementation lives on it's own)AbstractMap
(the basic functionality of the "new" map implementations)
HashMap
(the first concrete map implementation for general purpose use)
LinkedHashMap
(extends HashMap
by mainaining the linked list)