I know LinkedHashMap has a predictable iteration order (insertion order). Does the Set returned by LinkedHashMap.keySet() and the Collection returned by LinkedHashMap.values() also maintain this order?
I know LinkedHashMap has a predictable iteration order (insertion order). Does the Set returned
Share
— Map
— LinkedHashMap
So, yes,
keySet(),values(), andentrySet()(the three collection views mentioned) return values in the order the internal linked list uses. And yes, the JavaDoc forMapandLinkedHashMapguarantee it.That is the point of this class, after all.