title: How to compare two object arrays in Java?
body: <p>I have two object arrays like so:</p>
  
  <pre><code>Object[] array1 = {0, 1, 2, 3};
  Object[] array2 = {0, 1, 2, 3};
  </code></pre>
  
  <p>I would like to know if the arrays are equal.  I'm defining equal as every value in array1 is the same as the value in that position in the array2.  So these two arrays would be equal. </p>
  
  <p>What is the best why to find out if these two arrays are equal?</p>
  
  <pre><code>if(array1 == array2) 
  </code></pre>
  
  <p>is not a deep equals so that won't work and I don't know if looping over each element and comparing them is the best and most efficient way to solve this problem.   Does anyone have any better suggestions?</p>
  
  <p>Edit: I needed an equals that can go into nested arrays.</p>