Difference between LinkedHashmap and LinkedTreemap
This question already has an answer here:
For the performance part:
Hashmap
and LinkedHashMap
supports O(1) get/put operations complexity time. LinkedHashMap
preserves the order of the inserted items.
TreeMap
supports O(log n) get/put operations complexity time. Since it has a mechanism to preserver natural order of the items using Comparable
or Comparator
.
上一篇: HashMap可以始终保持相同的顺序?