Here are the main discussion of these three kinds: HashMap, Linkedhashmap, TreeMap 1. HashMap is a regular hash table, query and insert the best performance, if there is no special requirements, should use this
2. Linkedhashmap: This class is interesting, it can specify the order of traversal: 1) The order in which elements are added 2) in the least recently used order
The implementation of this class inherits HashMap, just more than HashMap maintains a doubly linked list, so its query and insert performance is slightly worse than HashMap. But its traversal performance is better than HashMap.
use Linkedhashmap If you want to traverse in order of element additions.
3. TreeMap, the internal implementation of this class is similar to the C + + std::mapTreeMap The element is stored in a red-black tree, the key stored in it must implement the comparable interface. Because of the use of red-black trees, the key stored in it is from small to large sequence. Its performance indicators are worse than hashmap.
If you want the elements in the map to be ordered, use TreeMap.
java-tip-the difference between various maps and how to choose