public V add(K key, V value)
{
   checkInitialization();
   if ((key == null) || (value == null))
      throw new IllegalArgumentException("Cannot add null to a dictionary.");
   else
   {
      V oldValue;                // Value to return

      int index = getHashIndex(key);
      index = probe(index, key); // Check for and resolve collision

      // Assertion: index is within legal range for hashTable
      assert (index >= 0) && (index < hashTable.length);

      if ( (hashTable[index] == null) || hashTable[index].isRemoved())
      { // Key not found, so insert new entry
         hashTable[index] = new TableEntry<>(key, value);
         numberOfEntries++;
         oldValue = null;
      }
      else
      { // Key found; get old value for return and then replace it
         oldValue = hashTable[index].getValue();
         hashTable[index].setValue(value);
      } // end if

      // Ensure that hash table is large enough for another add
      if (isHashTableTooFull())
         enlargeHashTable();

      return oldValue;
   } // end if
} // end add
// Version 4.0
