title: Java : hash function
body: <p>I am wondering if we implement our own hashmap that doesn't use power-of-two length hash tables (initial capacity and whenever we re-size), then in that case can we just use the object's hashcode and mod the total size directly instead of use a hash function to hash the object's hashcode ?</p>
  
  <p>for example</p>
  
  <pre><code>   public V put(K key, V value) {
           if (key == null)
               return putForNullKey(value);
           // int hash = hash(key.hashCode());     original way
           //can we just use the key's hashcode if our table length is not power-of-two ?
           int hash = key.hashCode();              
           int i = indexFor(hash, table.length);
           ...
           ...
       }
  </code></pre>