### Question:
HashMap extends Map<K, V> { @Override public void clear() { if (elementCount > 0) { elementCount = 0; for (int i = 0; i < elementData.length; i++) { elementData[i] = null; } modCount++; } } HashMap();  HashMap(int capacity);  HashMap(int capacity, float loadFactor);  HashMap(Map<K, V> map); @Override void clear(); @Override boolean containsKey(K key); @Override boolean containsValue(V value); @Override Set<MapEntry<K, V>> entrySet(); @Override V get(K key); @Override boolean isEmpty(); @Override Set<K> keySet(); @Override V put(K key, V value); @Override void putAll(Map<? extends K, ? extends V> map); @Override V remove(K key); @Override int size(); @Override Collection<V> values();  }### Answer:
@Test public void testClear() { hm.clear(); assertEquals("Clear failed to reset size", 0, hm.size()); for (int i = 0; i < hmSize; i++) { assertNull("Failed to clear all elements", hm.get(objArray2[i])); } HashMap<Integer, String> map = new HashMap<Integer, String>(); for (int i = -32767; i < 32768; i++) { map.put(i, "foobar"); } map.clear(); assertEquals("Failed to reset size on large integer map", 0, hm.size()); for (int i = -32767; i < 32768; i++) { assertNull("Failed to clear integer map values", map.get(i)); } }