Java Array Compare areEqual(byte[] a, byte[] b)

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

Description

Compares two byte arrays for equality.

License

Apache License

Parameter

Parameter Description
a A byte[].
b A byte[].

Return

True if the arrays have identical contents.

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  w  w w  .j  a va2s. co m*/
     * Compares two byte arrays for equality.
     *
     * @param a A byte[].
     * @param b A byte[].
     * @return True if the arrays have identical contents.
     */
    public static boolean areEqual(byte[] a, byte[] b) {
        int aLength = a.length;
        if (aLength != b.length) {
            return false;
        }

        for (int i = 0; i < aLength; i++) {
            if (a[i] != b[i]) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. areEqual(byte[] a, byte[] b)
  2. areEqual(byte[] a, byte[] b)
  3. areEqual(byte[] a, byte[] b)
  4. areEqual(byte[] array1, byte[] array2)
  5. AreEqual(double[] vector1, double[] vector2)
  6. areEqual(final byte[] a, final byte[] b)