Android Byte Array Equal equals(byte[] a1, byte[] a2)

Here you can find the source of equals(byte[] a1, byte[] a2)

Description

equals

Declaration

static public boolean equals(byte[] a1, byte[] a2) 

Method Source Code

//package com.java2s;

public class Main {

    static public boolean equals(byte[] a1, byte[] a2) {
        if ((a1 == null) || (a2 == null)) {
            return a1 == a2;
        }/*ww w  .j av  a 2 s  .c  o  m*/
        int nLength = a1.length;
        if (nLength != a2.length) {
            return false;
        }
        for (int i = 0; i < nLength; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    static public boolean equals(int[] a1, int[] a2) {
        if ((a1 == null) || (a2 == null)) {
            return a1 == a2;
        }
        int nLength = a1.length;
        if (nLength != a2.length) {
            return false;
        }
        for (int i = 0; i < nLength; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }
}

Related

  1. equals(final byte[] pArrayA, final int pOffsetA, final byte[] pArrayB, final int pOffsetB, final int pLength)
  2. equals(final byte[] pArrayA, final int pOffsetA, final byte[] pArrayB, final int pOffsetB, final int pLength)
  3. isEqual(byte[] first, byte[] second)
  4. equalByteArray(byte[] src, byte[] dst)
  5. equalByteArray(byte[] src, int srcOffset, int srcLen, byte[] dst, int dstOffset, int dstLen)
  6. equals(byte[] array1, byte[] array2)
  7. equals(byte[] left, byte[] right)
  8. equals(int[] a1, int[] a2)