### Question:
SimpleHashtable implements Iterable<TableEntry<K, V>> { public void put(K key, V value) { Objects.requireNonNull(key, "Key cannot be null."); if (slotIsEmpty(key)) { table[getSlotFromKey(key)] = new TableEntry<>(key, value); ++size; modificationCount++; } else { TableEntry<K, V> entry = findKey(key); if (entry.key.equals(key)) { entry.value = value; } else { entry.next = new TableEntry<>(key, value); ++size; modificationCount++; } } doubleIfNecessary(); } SimpleHashtable(); @SuppressWarnings("unchecked")  SimpleHashtable(int capacity); void put(K key, V value); V get(Object key); int size(); boolean containsKey(Object key); boolean containsValue(Object value); void remove(Object key); boolean isEmpty(); @Override String toString(); void clear(); int getCapacity(); @Override Iterator<TableEntry<K, V>> iterator(); static final int MINIMUM_CAPACITY; static final int DEFAULT_CAPACITY; }### Answer:
@Test void testPutWithNullKey() { assertThrows(NullPointerException.class, () -> createHashTableWithNElements(5).put(null, "stefica")); }
@SuppressWarnings("unchecked") @Test void testIteratingExampleFromPDF() { SimpleHashtable<String, Integer> examMarks = new SimpleHashtable<>(2); SimpleHashtable.TableEntry<String, Integer>[] table = new TableEntry[]{ new SimpleHashtable.TableEntry<>("Ante", 2), new SimpleHashtable.TableEntry<>("Ivana", 5), new SimpleHashtable.TableEntry<>("Jasna", 2), new SimpleHashtable.TableEntry<>("Kristina", 5), }; int index = 0; examMarks.put("Ivana", 2); examMarks.put("Ante", 2); examMarks.put("Jasna", 2); examMarks.put("Kristina", 5); examMarks.put("Ivana", 5); for(SimpleHashtable.TableEntry<String, Integer> pair : examMarks) { assertEquals(table[index], pair); ++index; } }