Does the collection obtained from the map.values ​​() method preserve the insertion order?

I have a copy LinkedHashMap

. LinkedHashMap

preserves the order of insertion. I need to get the values ​​of this card and I need them to be in the same order. So if I call a values()

method on this LinkedHashMap

one Collection

that I get from the method values()

guarantees the insertion order?

+3


source to share


1 answer


Yes, the LinkedHashMap source code contains an internal LinkedValues ​​class that remains in the order. An object of this class is returned by values ​​().



+3


source







All Articles