title: Combining Java hashcodes into a "master" hashcode
body: <p>I have a vector class with hashCode() implemented. It wasn't written by me, but uses 2 prime numbers by which to multiply the 2 vector components before XORing them. Here it is:</p>
  
  <pre><code>    /*class Vector2f*/
  ...
      public int hashCode()
      {
          return 997 * ((int)x) ^ 991 * ((int)y); //large primes! 
      }
  </code></pre>
  
  <p>...As this is from an established Java library, I know that it works just fine.</p>
  
  <p>Then I have a Boundary class, which holds 2 vectors, "start" and "end" (representing the endpoints of a line). The values of these 2 vectors are what characterize the boundary.</p>
  
  <pre><code>    /*class Boundary*/
  ...
      public int hashCode()
      {
          return 1013 * (start.hashCode()) ^ 1009 * (end.hashCode());
      }
  </code></pre>
  
  <p>Here I have attempted to create a good hashCode() for the unique 2-tuple of vectors (start &amp; end) constituting this boundary. My question: Is this hashCode() implementation going to work?</p>
  
  <p>(Note that I have used 2 different prime numbers in the latter hashCode() implementation; I don't know if this is necessary but better to be safe than sorry when trying to avoid common factors, I guess -- since I presume this is why primes are popular for hashing functions.)</p>