List of usage examples for java.util Arrays deepEquals
public static boolean deepEquals(Object[] a1, Object[] a2)
From source file:Main.java
public static void main(String[] args) { Object[] b1 = new Object[] { 'a', 'b' }; Object[] b2 = new Object[] { 'a', 'b' }; Object[] b3 = new Object[] { 'x', 'y' }; System.out.println(Arrays.deepEquals(b1, b2)); System.out.println(Arrays.deepEquals(b1, b3)); }
From source file:ArraysTester.java
public static void main(String[] args) { ArraysTester tester = new ArraysTester(50); int[] myArray = tester.get(); // Compare two arrays int[] myOtherArray = tester.get().clone(); if (Arrays.equals(myArray, myOtherArray)) { System.out.println("The two arrays are equal!"); } else {/* w w w. j a va2s . c o m*/ System.out.println("The two arrays are not equal!"); } // Fill up some values Arrays.fill(myOtherArray, 2, 10, new Double(Math.PI).intValue()); myArray[30] = 98; // Print array, as is System.out.println("Here's the unsorted array..."); System.out.println(Arrays.toString(myArray)); System.out.println(); // Sort the array Arrays.sort(myArray); // print array, sorted System.out.println("Here's the sorted array..."); System.out.println(Arrays.toString(myArray)); System.out.println(); // Get the index of a particular value int index = Arrays.binarySearch(myArray, 98); System.out.println("98 is located in the array at index " + index); String[][] ticTacToe = { { "X", "O", "O" }, { "O", "X", "X" }, { "X", "O", "X" } }; System.out.println(Arrays.deepToString(ticTacToe)); String[][] ticTacToe2 = { { "O", "O", "X" }, { "O", "X", "X" }, { "X", "O", "X" } }; String[][] ticTacToe3 = { { "X", "O", "O" }, { "O", "X", "X" }, { "X", "O", "X" } }; if (Arrays.deepEquals(ticTacToe, ticTacToe2)) { System.out.println("Boards 1 and 2 are equal."); } else { System.out.println("Boards 1 and 2 are not equal."); } if (Arrays.deepEquals(ticTacToe, ticTacToe3)) { System.out.println("Boards 1 and 3 are equal."); } else { System.out.println("Boards 1 and 3 are not equal."); } }
From source file:Main.java
public static boolean deepEquals(Object[] x, Object[] y) { return Arrays.deepEquals(x, y); }
From source file:Main.java
/** *Convenience method for checking if a list of arrays of objects contains a given array *Have to implement this because arrlist.contains uses .equals() to check equality *But this does only shallow checking. To check equality of arrays of objects, one should use *Arrays.deepEquals//w w w . j a va 2s .com * */ public static boolean deepContainsArray(List<? extends Object[]> list, Object[] oarr) { for (Object[] objarr : list) { if (Arrays.deepEquals(objarr, oarr)) { return true; } } return false; }
From source file:com.opengamma.analytics.financial.model.volatility.SmileAndBucketedSensitivities.java
@Override public boolean equals(final Object obj) { if (this == obj) { return true; }//from www.j ava 2 s.c om if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final SmileAndBucketedSensitivities other = (SmileAndBucketedSensitivities) obj; if (!ObjectUtils.equals(_smile, other._smile)) { return false; } if (!Arrays.deepEquals(_sensitivities, other._sensitivities)) { return false; } return true; }
From source file:io.fouad.jtb.core.beans.UserProfilePhotos.java
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UserProfilePhotos that = (UserProfilePhotos) o; if (totalCount != that.totalCount) return false; return Arrays.deepEquals(photos, that.photos); }
From source file:io.fouad.jtb.core.beans.InlineKeyboardMarkup.java
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof InlineKeyboardMarkup)) return false; InlineKeyboardMarkup that = (InlineKeyboardMarkup) o; return Arrays.deepEquals(inlineKeyboard, that.inlineKeyboard); }
From source file:org.grouplens.grapht.util.ConstructorProxy.java
@Override public boolean equals(Object o) { if (o == this) { return true; } else if (o instanceof ConstructorProxy) { ConstructorProxy op = (ConstructorProxy) o; return declaringClass.equals(op.declaringClass) && Arrays.deepEquals(parameterTypes, op.parameterTypes); } else {/*from w w w. j a va 2 s . co m*/ return true; } }
From source file:com.igormaznitsa.jcp.expression.functions.AbstractFunctionTest.java
protected void assertAllowedArguments(final AbstractFunction function, final ValueType[][] checkingData) { final ValueType[][] argTypes = function.getAllowedArgumentTypes(); for (final ValueType[] currentTypes : argTypes) { boolean found = false; for (final ValueType[] etalon : checkingData) { if (Arrays.deepEquals(currentTypes, etalon)) { found = true;//from www. j av a2s . co m break; } } if (!found) { fail("Found not allowed argument types " + Arrays.toString(currentTypes)); } } }
From source file:org.grouplens.grapht.util.MethodProxy.java
@Override public boolean equals(Object o) { if (o == this) { return true; } else if (o instanceof MethodProxy) { MethodProxy op = (MethodProxy) o; return declaringClass.equals(op.declaringClass) && methodName.equals(op.methodName) && Arrays.deepEquals(parameterTypes, op.parameterTypes); } else {/*from w w w.j ava 2 s . co m*/ return true; } }