LruCache extends LinkedHashMap<K, V> { public static <K, V> LruCache<K, V> create(int maxSize) { return new LruCache<K, V>(maxSize); } private  LruCache(int maxSize); static LruCache<K, V> create(int maxSize); int getMaxSize();  }
@Test public void testCache() { LruCache<String, String> cache = LruCache.create(4); cache.put("a", "a1"); cache.put("b", "b1"); cache.put("c", "c1"); cache.put("d", "d1"); cache.put("e", "e1"); assertFalse(cache.containsKey("a")); assertEquals("b1", cache.get("b")); cache.put("f", "f1"); assertFalse(cache.containsKey("c")); cache.put("g", null); assertTrue(cache.containsKey("g")); assertNull(cache.get("g")); assertFalse(cache.containsKey("d")); assertNull(cache.get("d")); }