is Byte array Equal - Java java.lang

Java examples for java.lang:byte Array Compare

Description

is Byte array Equal

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        byte[] first = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        byte[] second = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(isEqual(first, second));
    }/*from   ww w  .  jav a 2  s  .  c o m*/

    public static boolean isEqual(byte[] first, byte[] second) {
        boolean out = first != null && second != null
                && first.length == second.length;
        for (int i = 0; out && i < first.length; i++) {
            if (first[i] != second[i]) {
                out = false;
            }
        }
        return out;
    }
}

Related Tutorials