Java Array Equal arraysAreEqual(final byte[] array1, final byte[] array2)

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

Description

Check if two byte arrays are equal.

License

Open Source License

Parameter

Parameter Description
array1 The first array
array2 the second array

Return

Returns true if the arrays are equal otherwise false

Declaration

public static final boolean arraysAreEqual(final byte[] array1, final byte[] array2) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   ww  w .j  a  v  a  2  s .  co  m*/
     * Check if two byte arrays are equal.
     * 
     * @param array1 The first array
     * @param array2 the second array
     * @return Returns true if the arrays are equal otherwise false
     */
    public static final boolean arraysAreEqual(final byte[] array1, final byte[] array2) {
        if (array1.length != array2.length)
            return false;

        for (int i = 0; i < array1.length; i++) {
            if (array1[i] != array2[i])
                return false;
        }

        return true;
    }
}

Related

  1. arrayEquals(String[] array1, String[] array2)
  2. arrayEquals(String[] targetMethodParamTypes, String[] paramTypes)
  3. arrayEqualsExceptNull(Object[] a1, Object[] a2)
  4. arrayEqualsSubset(final byte[] array, final int... elements)
  5. arraysAreEqual(double[] a1, double[] a2)
  6. arraysAreEqual(Object value, Object otherValue)
  7. arraysEqual(boolean[] a, boolean[] b)
  8. arraysEqual(byte array1[], byte array2[])
  9. arraysEqual(byte[] bytes, byte[] ints)