Friday, 4 September 2015

Collection : What are the differences between Map, Hashtable, HashMap, TreeMap, ConcurrentHashMap, LinkedHashMap?

  • Map is an interface for a key-value map
  • HashMap is a Map that uses a hash table for its implementation
  • Hashtable is a synchronized version of HashMap
  • TreeMap uses a tree to implement a map
  • ConcurrentHashMap allows for multiple threads to access it at the same time safely
  • LinkedHashMap preserves the iteration order that things were inserted in (others don’t provide a fixed iteration order)
A deeper discussion of the differences can be found in Advanced Java Programming.

No comments:

Post a Comment