Compares the two boolean arrays deeply - Java Collection Framework

Java examples for Collection Framework:Array Element

Description

Compares the two boolean arrays deeply

Demo Code


//package com.java2s;

public class Main {
    /**// w  w  w  . j ava 2s  . c  om
     * Compares the two boolean arrays deeply
     * @param array1
     * @param array2
     * @return false if arrays have different length or different values at a specific index,
     * true otherwise
     */
    public static boolean deepEquals(boolean[] array1, boolean[] 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 Tutorials