title: Java - Compare 2 int Arrays and judge them based on their values
body: <p>I have a set of 2 int Arrays containing the same amount of numbers</p>
  
  <p>for example</p>
  
  <pre><code>int[] array1 = {1,3,5,5,2}
  int[] array2 = {5,3,4,4,4}
  </code></pre>
  
  <p>I need to compare them based on 2 criteria</p>
  
  <ol>
  <li>How many elements have the same value on the same index</li>
  <li>How many elements have the same value on a different index</li>
  </ol>
  
  <p>And return an array of integers presenting the values</p>
  
  <p>I have a few examples so you can understand better:</p>
  
  <pre><code>   int[] array0 = {1,3,5,5,2};
     int[] array1 = {5,3,4,4,4};
     int[] array2 = {5,3,4,4,5};
     int[] array3 = {2,3,2,2,4};
     int[] array4 = {5,5,2,1,3};
     int[] array5 = {3,1,5,5,2};
     int[] array6 = {1,3,5,5,2};
  
     compare(array0,array1); //this would return 1,1
     compare(array0,array2); //this would return 1,2
     compare(array0,array3); //this would return 1,1
     compare(array0,array4); //this would return 0,5
     compare(array0,array5); //this would return 3,2
     compare(array0,array6); //this would return 5,0
  </code></pre>
  
  <p>For the first number it's easy, I just need to check if element on index i of array1 is the same as in array2.</p>
  
  <p>I have problems producing the second number because the lowest number from one of the arrays should be taken.
  If I just look if element of array1 is somewhere in array2 it produces a wrong result in some cases.</p>
  
  <p>if you look at </p>
  
  <pre><code>int[] array1 = {1,3,5,5,2}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>int[] array3 = {2,3,2,2,4};
  </code></pre>
  
  <p>and check if array1 has the same contents as array3 on an index, it would return 3 numbers are equal but on a different spot which is wrong because it should judge from the lowest number and the result there should be 1.</p>
  
  <p>If I switch it around to compare if array3 has the same contents as array1 on some index it works for this case but not for others.</p>
  
  <p>Any ideas on how to approach this, I'm pretty clueless?</p>