Java Array Equal equalityCheck(byte[] a, byte[] b)

Here you can find the source of equalityCheck(byte[] a, byte[] b)

Description

Checks for variety of equality conditions.

License

Open Source License

Parameter

Parameter Description
a a parameter
b a parameter

Return

1. If byte[] reference are equal than return true 2. If only one of the byte[] reference is null than return false 3. return if contents of a is equal to b via Arrays.equals(a,b)

Declaration

public static boolean equalityCheck(byte[] a, byte[] b) 

Method Source Code


//package com.java2s;
import java.util.Arrays;

public class Main {
    /**/*from  w  w  w  . j av  a2s.  c om*/
     * Checks for variety of equality conditions.
     *
     * @param a
     * @param b
     * @return 1. If object reference are equal than return true 2. If only one of the object reference is null than
     * return false 3. return if contents of a is equal to b via a.equals(b)
     */
    public static boolean equalityCheck(Object a, Object b) {
        if (a == b)
            return true;
        if (a == null || b == null)
            return false;
        return a.equals(b);
    }

    /**
     * Checks for variety of equality conditions.
     *
     * @param a
     * @param b
     * @return 1. If byte[] reference are equal than return true 2. If only one of the byte[] reference is null than
     * return false 3. return if contents of a is equal to b via Arrays.equals(a,b)
     */
    public static boolean equalityCheck(byte[] a, byte[] b) {
        if (a == b)
            return true;
        if (a == null || b == null)
            return false;
        return Arrays.equals(a, b);
    }
}

Related

  1. equal(float[][] array1, float[][] array2)
  2. equal(int[] a, int[] b)
  3. equalByRows(boolean[][] a, boolean[][] b)
  4. equalFreqBinning(double[][] sampleData, int numPredVals, int numRespVals, int divInd)
  5. equalIgnoreOrder(final Object[] array1, final Object[] array2)
  6. equalMaps(Map expected, Map actual)
  7. equalOrDie(String testName, Object[] a, Object[] b)
  8. equals(byte[] a, byte[] b)
  9. equals(byte[] a1, byte[] a2)