Create a LRU cache that can hold five objects maximum at a time, and write the get, add, and remove functions for it. If you add an item to the cache with five items in it, the least accessed item should be removed, and your item should be added to the top of the cache.
Sigiloso
class LRU extends LinkedHashMap { private final int maxCapacity; public LRU(int maxCapacity) { this.maxCapacity = maxCapacity; super(maxCapcity, 1.0, true); } protected boolean removeEldestEntry(Map.Entry eldest) { return size() > maxCapacity; } }