集册 Java实例教程 检查两个深度相等的数组

检查两个深度相等的数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

763
检查两个深度相等的数组

/*
n o w j a   v  a . c o m - 时  代  Java 提 供
*/

//package com.nowjava;


public class Main {

    /**

     * Checks if 2 arrays deep equal each other

     * @param src      The first array

     * @param dest      The second array

     * @return         | if(src == null || dest == null)

     *                |       result == (src == null) && (dest == null)

     * @return         | if(src.length != dest.length)

     *                |      result == false

     * @return         | if(

     *                |      for each int rowNumber in 0..src.length-1:

     *                |         src[rowNumber].length == dest[rowNumber].length

     *                |         && for each int columNumber in 0..src[rowNumber].length-1

     *                |               src[rowNumber][columNumber] == dest[rowNumber][columnNumber]

     *                | )

     *                | then result == true

     *                | else result == false

     */

    public static boolean deepEquals(boolean[][] src, boolean[][] dest) {

        if (src == null || dest == null)

            return (src == null) && (dest == null);


        if (src.length != dest.length)

            return false;


        for (int i = 0; i < src.length; i++) {/*时代Java - nowjava.com 提供*/

            if (src[i].length != dest[i].length)

                return false;
展开阅读全文