Java Utililty Methods Array Equal

List of utility methods to do Array Equal

Description

The list of methods to do Array Equal are organized into topic(s).

Method

booleanequal(byte[] a, byte[] b)
DEPRECATED, use Arrays.equals
return Arrays.equals(a, b);
booleanequal(float[][] array1, float[][] array2)
Tests two float arrays for equality.
if (array1 == null) {
    return (array2 == null);
if (array2 == null) {
    return false;
if (array1.length != array2.length) {
    return false;
...
booleanequal(int[] a, int[] b)
Checks if a[i] == b[i] for all i from 0 to a.length (= b.length)
return Arrays.equals(a, b);
booleanequalByRows(boolean[][] a, boolean[][] b)
equal By Rows
if (a.length != b.length)
    return false;
boolean eqRow;
boolean[] bUsed = new boolean[b.length];
Arrays.fill(bUsed, false);
for (int i = 0; i < a.length; i++) {
    eqRow = false;
    for (int j = 0; j < b.length; j++) {
...
voidequalFreqBinning(double[][] sampleData, int numPredVals, int numRespVals, int divInd)
Performs a simple binning of the response values.
if (sampleData.length > 0) {
    double[][] inds = new double[sampleData[0].length][Math.max(numPredVals, numRespVals)];
    int num = numPredVals;
    for (int r = 0; r < sampleData[0].length; r++) {
        if (r == divInd) {
            num = numRespVals;
        double[] singleData = new double[sampleData.length];
...
booleanequalIgnoreOrder(final Object[] array1, final Object[] array2)
equal Ignore Order
final class HashComparator<T> implements Comparator<T> {
    public int compare(final T o1, final T o2) {
        if (o1 == null && o2 == null) {
            return 0;
        if (o1 == null && o2 != null) {
            return -1;
        if (o1 != null && o2 == null) {
            return 1;
        return (o1.hashCode() - o2.hashCode());
if (array1 == null && array2 != null) {
    return false;
if (array1 != null && array2 == null) {
    return false;
if (array1 == null && array2 == null) {
    return true;
if (array1.length != array2.length) {
    return false;
final Object[] sortedArray1 = dup(array1);
final Object[] sortedArray2 = dup(array2);
Arrays.sort(sortedArray1, new HashComparator<Object>());
Arrays.sort(sortedArray2, new HashComparator<Object>());
return Arrays.equals(sortedArray1, sortedArray2);
booleanequalityCheck(byte[] a, byte[] b)
Checks for variety of equality conditions.
if (a == b)
    return true;
if (a == null || b == null)
    return false;
return Arrays.equals(a, b);
booleanequalMaps(Map expected, Map actual)
equal Maps
for (Map.Entry<String, String[]> expectedEntry : expected.entrySet()) {
    String[] expectedArray = expectedEntry.getValue();
    String[] actualArray = actual.get(expectedEntry.getKey());
    if (actualArray == null) {
        return false;
    } else {
        boolean result = equalStringArrays(expectedArray, actualArray);
        if (!result) {
...
voidequalOrDie(String testName, Object[] a, Object[] b)
equal Or Die
if (!Arrays.equals(a, b)) {
    throw new Exception(testName + " failed, arrays are not equal");
booleanequals(byte[] a, byte[] b)
equals
return Arrays.equals(a, b);