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
They all honor the same contract, but there are some differences in the implementation:
Generally, the best practice is to use Map
as the type for variables, and then you instantiate an implementing type based on the needs of your code. HashMap
is generally preferred unless you need some ordering guarantees, in which case LinkedHashMap
or TreeMap
are good choices.