Java Array Compare areEqual(byte[] array1, byte[] array2)

Here you can find the source of areEqual(byte[] array1, byte[] array2)

Description

Determine if the two passed arrays have exactly the same values.

License

Open Source License

Parameter

Parameter Description
array1 The first array.
array2 The second array.

Return

true if the arrays are equel, otherwise false.

Declaration

public static boolean areEqual(byte[] array1, byte[] array2) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  w  ww  .j ava2s .c om
     * Determine if the two passed arrays have exactly the same values.
     *
     * @param   array1  The first array.
     * @param   array2  The second array.
     *
     * @return  true if the arrays are equel, otherwise false.
     *
     * @author  M. Del Pellegrino
     * @since   1
     */
    public static boolean areEqual(byte[] array1, byte[] array2) {
        boolean equality;

        if (array1.length == array2.length) {
            equality = true;
            for (int loop = 0; equality && loop < array1.length; loop++) {
                if (array1[loop] != array2[loop]) {
                    equality = false;
                }
            }
        } else {
            equality = false;
        }

        return equality;
    }
}

Related

  1. areEqual(byte[] a, byte[] b)
  2. areEqual(byte[] a, byte[] b)
  3. areEqual(byte[] a, byte[] b)
  4. areEqual(byte[] a, byte[] b)
  5. AreEqual(double[] vector1, double[] vector2)
  6. areEqual(final byte[] a, final byte[] b)
  7. areEqualBytes(byte[] b1, byte[] b2)
  8. areEqualPropPaths(String[] pp1, String[] pp2)