Java Array Equal equals(final T[][] a, final T[][] b)

Here you can find the source of equals(final T[][] a, final T[][] b)

Description

equals

License

Apache License

Declaration

public static <T> boolean equals(final T[][] a, final T[][] b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static <T> boolean equals(final T[][] a, final T[][] b) {
        if (a == b) {
            return true;
        }/*from  ww  w .j a  va2s .  c o m*/
        if (a == null || b == null) {
            return false;
        }
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (!Arrays.equals(a[i], b[i])) {
                return false;
            }
        }
        return true;
    }

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

    public static <T> boolean equals(final T[][][] a, final T[][][] b) {
        if (a == b) {
            return true;
        }
        if (a == null || b == null) {
            return false;
        }
        if (a.length != b.length) {
            return false;
        }
        for (int i = 0; i < a.length; ++i) {
            if (!equals(a[i], b[i])) {
                return false;
            }
        }
        return true;
    }

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

Related

  1. equals(char[][] c1, char[][] c2)
  2. equals(Collection asCollection, String[] values)
  3. equals(double[][] xs, double[][] ys)
  4. equals(final byte[] a, final byte[] b)
  5. equals(final byte[] array1, final byte[] array2)
  6. equals(int[] a, int[] b)
  7. equals(int[][] ar1, int[][] ar2)
  8. equals(long[] a, long[] a2)
  9. equals(Map a, Map b)