title: Java hashcode() collision for objects containing different but similar Strings
body: <p>While verifying output data of my program, I identified cases for which hash codes of two different objects were identical. To get these codes, I used the following function:</p>
  
  <pre><code>int getHash( long lID, String sCI, String sCO, double dSR, double dGR, String sSearchDate ) {
  
      int result = 17;
      result = 31 * result + (int) (lID ^ (lID &gt;&gt;&gt; 32));
      long temp;
      temp = Double.doubleToLongBits(dGR);
      result = 31 * result + (int) (temp ^ (temp &gt;&gt;&gt; 32));
      temp = Double.doubleToLongBits(dSR);
      result = 31 * result + (int) (temp ^ (temp &gt;&gt;&gt; 32));
      result = 31 * result + (sCI != null ? sCI.hashCode() : 0);
      result = 31 * result + (sCO != null ? sCO.hashCode() : 0);
      result = 31 * result + (sSearchDate != null ? sSearchDate.hashCode() : 0);
  
      return result;
  }
  </code></pre>
  
  <p>These are two example cases:</p>
  
  <pre><code>getHash( 50122,"03/25/2015","03/26/2015",4.0,8.0,"03/24/15 06:01" )
  getHash( 51114,"03/24/2015","03/25/2015",4.0,8.0,"03/24/15 06:01" )
  </code></pre>
  
  <p>I suppose, this issue arises, as I have three very similar strings present in my data, and the difference in the hashcode between String A to B and B to C are of the same size, leading to an identical returned hashcode. </p>
  
  <p>The proposed hashcode() implementation by IntelliJ is using 31 as a multiplier for each variable that contributes to the final hashcode. I was wondering why one is not using different values for each variable (like 33, 37, 41 (which I have seen mentioned in other posts dealing with hashcodes))? In my case, this would lead to a differentiation between my two objects. </p>
  
  <p>But I'm wondering whether this could then lead to issues in other cases?</p>
  
  <p>Any ideas or hints on this? Thank you very much!</p>