src/share/classes/java/util/Arrays.java

Print this page

        

*** 3926,3935 **** --- 3926,3936 ---- * * @param a1 one array to be tested for equality * @param a2 the other array to be tested for equality * @return <tt>true</tt> if the two arrays are equal * @see #equals(Object[],Object[]) + * @see Objects#deepEquals(Object, Object) * @since 1.5 */ public static boolean deepEquals(Object[] a1, Object[] a2) { if (a1 == a2) return true;
*** 3947,3956 **** --- 3948,3967 ---- continue; if (e1 == null) return false; // Figure out whether the two elements are equal + boolean eq = deepEquals0(e1, e2); + + if (!eq) + return false; + } + return true; + } + + static boolean deepEquals0(Object e1, Object e2) { + assert e1 != null; boolean eq; if (e1 instanceof Object[] && e2 instanceof Object[]) eq = deepEquals ((Object[]) e1, (Object[]) e2); else if (e1 instanceof byte[] && e2 instanceof byte[]) eq = equals((byte[]) e1, (byte[]) e2);
*** 3968,3982 **** eq = equals((double[]) e1, (double[]) e2); else if (e1 instanceof boolean[] && e2 instanceof boolean[]) eq = equals((boolean[]) e1, (boolean[]) e2); else eq = e1.equals(e2); ! ! if (!eq) ! return false; ! } ! return true; } /** * Returns a string representation of the contents of the specified array. * The string representation consists of a list of the array's elements, --- 3979,3989 ---- eq = equals((double[]) e1, (double[]) e2); else if (e1 instanceof boolean[] && e2 instanceof boolean[]) eq = equals((boolean[]) e1, (boolean[]) e2); else eq = e1.equals(e2); ! return eq; } /** * Returns a string representation of the contents of the specified array. * The string representation consists of a list of the array's elements,