title: Getting index of a key in a Hashtable in Java
body: <p>I am writing an implementation of a Dictionary class. I am currently writing the add method</p>
  
  <p>(public V <strong>add</strong> (K key, V value))</p>
  
  <p>Algorithm:</p>
  
  <pre><code>if the table is too full
      rehash
  grab the index based on the key
  probe with the index and key to resolve collisions
  if the table at the index is null, or has been removed
      increment the number of entries
      increment the number of locations used
      set the table at that index to a new tableentry
  else
      grab the value currently at that index
      set the value at the index to the new value
  return the old value
  </code></pre>
  
  <p>I can't figure out how to grab the index based on the key provided. I also don't know how to refer to a specific index in a Hashtable.</p>
  
  <p>Thanks</p>