public class LRUCache extends LinkedHashMap {
private static float loadFactor = 0.75f;
private static LRUCache cache ;
int size;
private LRUCache(int size) {
super(size, loadFactor, true);
this.size = size;
}
public static LRUCache getInstance(int size) {
return new LRUCache(size);
}
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
return size() > size;
}
}