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.
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.
At the moment this is printing size 2, I want it to be printing size 1:
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());
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.