From the Java docs for Arrays.equals(Object[] a, Object[] a2):
Returns true 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.
But when I ran the program below it is printing false as output.
So, Does the mean equals method of the Array class not work for multidimensional arrays?
What API can I use to achieve true as the result in the program below?
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));
}
}