will an hashcode ever give a negative value? : <p>In the code given, it was trying to give a valid index for a hashtable by checking for any collision using another method linearprobe. I am just confuse of why we need to check for index &lt; 0, so will there be instance when hashCode will be negative? When/why will that happens?</p>

<pre><code>private int getHashIndex(K key)
{
   //1.convert key to hashcode, then get the index;
  //2. then use linear probing to check for the correct index;
  int index = key.hashCode() % hashTable.length; 
  if(index &lt; 0) { //So a hash code can be negative?
    index += hashTable.length;
  }

  index = linearProbe(index,key);

  return index;

}
</code></pre>
