title: How to use String.hashCode to generate primary keys
body: <p>I understand that this seems to be already discussed and the answer is yes, <code>String.hashCode</code> can generate equal vales for different strings, but quite unlikely (<a href="https://stackoverflow.com/questions/10102337/javas-hashcode-can-produce-same-hashcode-for-different-strings">Can Java&#39;s hashCode produce same value for different strings?</a>). However it does happen in my application.</p>
  
  <p>The following code will produce the same hashcode: -347019262 (jave 1.7.25)</p>
  
  <pre><code>String string1 = "/m/06qw_";
  String string2="/m/0859_";
  System.out.println(string1+","+string1.hashCode());
  System.out.println(string2+","+string2.hashCode());
  </code></pre>
  
  <p>I do need hashcode in this case, and I want to use it to generate a unique primary key for a string. it seems that I am not doing it right. Any suggestions please?</p>
  
  <p>Many thanks!</p>