LinkedHashMap extends AbstractMap<K, V> implements Map<K, V> { @NotNull @Override public Set<K> keySet() { return new KeySet(); } LinkedHashMap();  LinkedHashMap(int capacity);  LinkedHashMap(int capacity, boolean accessOrder);  LinkedHashMap(int capacity, float loadFactor);  LinkedHashMap(int capacity, float loadFactor, boolean accessOrder);  LinkedHashMap(EqualityPolicy<K> hashingStrategy);  LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<K> hashingStrategy);  LinkedHashMap(int capacity, float loadFactor, EqualityPolicy<K> hashingStrategy, boolean accessOrder); @Override int size(); @Override boolean isEmpty(); @Override void clear(); @Override V get(final Object key); @Override V put(final K key, @NotNull final V value); void doRemoveEldestEntry(); @Override boolean containsKey(final Object key); @Override V remove(final Object key); @NotNull @Override Set<K> keySet(); @NotNull @Override Collection<V> values(); @NotNull @Override Set<Map.Entry<K, V>> entrySet(); @Nullable K getLastKey(); @Nullable V getLastValue();  }
@Test public void keySet() { final LinkedHashMap<Integer, String> tested = new LinkedHashMap<Integer, String>(); for (int i = 0; i < 10000; ++i) { tested.put(i, Integer.toString(i)); } int i = 0; for (Integer key : tested.keySet()) { assertEquals(i++, key.intValue()); } }