The JDK documentation on java.util.Map states
The order of a map is defined as the
order in which the iterators on the
map’s collection views return their
elements. Some map implementations,
like the TreeMap class, make specific
guarantees as to their order; others,
like the HashMap class, do not.
And the documentation on TreeMap states:
The map is sorted according to the
natural ordering of its keys, or by a
Comparator provided at map creation
time, depending on which constructor
is used.
Is there any JDK implementation of Map that uses the order that elements were inserted into the map as the order?
java.util.LinkedHashMap: