Here you can find the source of arrayCompare(byte[] a, byte[] a2)
Parameter | Description |
---|---|
a | one array to be tested for equality |
a2 | the other array to be tested for equality |
public static boolean arrayCompare(byte[] a, byte[] a2)
//package com.java2s; /*//from ww w . j a v a 2 s . c o m * Util - Some useful small methods for NFCIPConnection * * Copyright (C) 2009 Fran?ois Kooman <F.Kooman@student.science.ru.nl> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ public class Main { /** * Returns <tt>true</tt> if the two specified arrays of bytes are * <i>equal</i> to one another. Two arrays are considered equal if both * arrays contain the same number of elements, and all corresponding pairs * of elements in the two arrays are equal. In other words, two arrays are * equal if they contain the same elements in the same order. Also, two * array references are considered equal if both are <tt>null</tt>. * <p> * * @param a * one array to be tested for equality * @param a2 * the other array to be tested for equality * @return <tt>true</tt> if the two arrays are equal */ public static boolean arrayCompare(byte[] a, byte[] a2) { if (a == a2) return true; if (a == null || a2 == null) return false; int length = a.length; if (a2.length != length) return false; for (int i = 0; i < length; i++) if (a[i] != a2[i]) return false; return true; } }