title: Using an array as a hash key in Java?
body: <p>I have a function that does some calculations. It accepts a int array and returns an integer based on the contents of the int array that's passed to it.</p>
  
  <p>As my application is doing hundreds of theses calculations I'm trying to set up a way to store those calculation results in a hashmap so it don't have to recalculate the calculation it already did recently. To do this though I'd need to use the int arrays as my keys to the hashmap.</p>
  
  <p>At the moment this is printing size 2, I want it to be printing size 1:</p>
  
  <pre><code>LinkedHashMap hashmap = new LinkedHashMap();
  
  int test[] = {1,2,3};
  int test2[] = {1,2,3};
  
  hashmap.put(test, 1);
  hashmap.put(test2, 1);
  
  System.out.println("Size: "+hashmap.size());
  </code></pre>
  
  <p>What's the best way to achieve this? I could create a method to convert the arrays to some kind of string encoding the arrays data but I don't think that would be the best solution.</p>