title: How to compare two-dimensional (or nested) Java Arrays?
body: <p>From the Java docs for <strong>Arrays.equals(Object[] a, Object[] a2)</strong>:</p>
  
  <blockquote>
    <p>Returns <strong>true</strong> if the two specified arrays of Objects are equal to one
    another. The two arrays are considered equal if both arrays contain
    the same number of elements, and all corresponding pairs of elements
    in the two arrays are equal. </p>
  </blockquote>
  
  <p>But when I ran the program below it is printing <code>false</code> as output.</p>
  
  <p>So, Does the mean <code>equals</code> method of the <code>Array</code> class not work for multidimensional arrays?</p>
  
  <p>What API can I use to achieve <code>true</code> as the result in the program below?</p>
  
  <pre><code>public class Test {
      public static void main(String[] args) {
          String[][] rows1 = { new String[] { "a", "a" } };
  
          String[][] rows2 = { new String[] { "a", "a" } };
  
          System.out.println("Arrays.equals() = " + Arrays.equals(rows1, rows2));
  
      }
  }
  </code></pre>