HashMap can keep always the same order?

This question already has an answer here:

  • Difference between HashMap, LinkedHashMap and TreeMap 16 answers

  • 如果您使用LinkedHashMap,则顺序将保持不变(即,默认情况下,键将始终按照插入到Map中的顺序迭代)。


    If the keys and values are always the same, the map size is the same, and the HashMap is initialized in the same way, then yes. However for guaranteed iteration order, use a LinkedHashMap .

    链接地址: http://www.djcxy.com/p/92178.html

    上一篇: 谁在Java中更快的hashmap.get或treemap.get

    下一篇: HashMap可以始终保持相同的顺序?