title: Why use a prime number in hashCode?
body: <p>I was just wondering why is that primes are used in a class's <code>hashCode()</code> method? For example, when using Eclipse to generate my <code>hashCode()</code> method there is always the prime number <code>31</code> used:</p>
  
  <pre><code>public int hashCode() {
       final int prime = 31;
       //...
  }
  </code></pre>
  
  <p><strong>References:</strong></p>
  
  <p>Here is a good primer on Hashcode and article on how hashing works that I found (C# but the concepts are transferrable):
  <a href="http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/" rel="noreferrer">Eric Lippert's Guidelines and rules for GetHashCode()</a></p>