Skip to main content

Note from LinkedHashMap's javadoc:

Note that insertion order is not affected if a key is re-inserted into the map

So this will not be an LRU map unless you make sure that all keys are unique.

Further in the documentation, however:

A special constructor is provided to create a linked hash map whose order of iteration is the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order). This kind of map is well-suited to building LRU caches.

Note from LinkedHashMap's javadoc:

Note that insertion order is not affected if a key is re-inserted into the map

So this will not be an LRU map unless you make sure that all keys are unique.

Note from LinkedHashMap's javadoc:

Note that insertion order is not affected if a key is re-inserted into the map

So this will not be an LRU map unless you make sure that all keys are unique.

Further in the documentation, however:

A special constructor is provided to create a linked hash map whose order of iteration is the order in which its entries were last accessed, from least-recently accessed to most-recently (access-order). This kind of map is well-suited to building LRU caches.

Source Link

Note from LinkedHashMap's javadoc:

Note that insertion order is not affected if a key is re-inserted into the map

So this will not be an LRU map unless you make sure that all keys are unique.