LinkedHashMap is a variant of HashMap. Its entries are kept in a doubly-linked list. The iteration order is, by default, the order in which keys were inserted. Reinserting an already existing key doesn't change the order. A key is existing if a call to {@code containsKey} would return true.
If the three argument constructor is used, and {@code order} is specified as{@code true}, the iteration will be in the order that entries were accessed. The access order gets affected by put(), get(), putAll() operations, but not by operations on the collection views.
Null elements are allowed, and all the optional map operations are supported.
Note: The implementation of {@code LinkedHashMap} is not synchronized.If one thread of several threads accessing an instance modifies the map structurally, access to the map needs to be synchronized. For insertion-ordered instances a structural modification is an operation that removes or adds an entry. Access-ordered instances also are structurally modified by put(), get() and putAll() since these methods change the order of the entries. Changes in the value of an entry are not structural changes.
The Iterator that can be created by calling the {@code iterator} methodthrows a {@code ConcurrentModificationException} if the map is structurallychanged while an iterator is used to iterate over the elements. Only the {@code remove} method that is provided by the iterator allows for removal ofelements during iteration. It is not possible to guarantee that this mechanism works in all cases of unsynchronized concurrent modification. It should only be used for debugging purposes.
@since 1.4