After reading the documentation for LinkedHashMap (and having used it several times), I’m still not clear about one of its properties…is the iteration order for a LinkedHashMap:
- the same as insertion order for
entrySet(),keySet(), andvalues(), or - the same as insertion order for
entrySet()andkeySet()but notvalues(), or - only the same as insertion order for
entrySet()?
I imagine the third scenario to be unlikely, but I would like to know if anyone knows if (1) or (2) is true since iteration over values() is probably a rare use case.
LinkedHashMaprespects insertion order; so the first choice is the good.A
Mapbeing a set ofMap.Entryobjects, options 2 and 3 would be rather strange 😉