A Map can provide faster access.
If you use a List you need to loop through the entire List until you get a match (linear searching). With a HashMap, the access is nearly instantaneous - using the hash code a very small subset of entries (called buckets, ideally only one element) is retrieved and that is searched like a List. This is in the end a lot faster than a List.
With TreeMap the access is a bit slower but still faster than linear. The elements are spread out like a binary tree. Each node (also non-leaf nodes) has an element and at most two children. Lookup is determined by starting at the root using this algorithm:
- if the element's match then stop at that element
- if the element is larger than check the left sub tree
- if the element is smaller than check the right sub tree
All in all, for a simple lookup a List is
O(n) (linear), a HashMap is O(1) (constant) and a TreeMap is O(log(n)) (logarithmic).