Java Array Equal equals(int[][] ar1, int[][] ar2)

Here you can find the source of equals(int[][] ar1, int[][] ar2)

Description

equals

License

Apache License

Declaration

public static boolean equals(int[][] ar1, int[][] ar2) 

Method Source Code

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

import java.util.Arrays;

import java.util.List;

public class Main {
    public static boolean equals(int[][] ar1, int[][] ar2) {
        if (ar1.length != ar2.length)
            return false;
        for (int[] row1 : ar1) {
            if (!contains(row1, ar2)) {
                return false;
            }/* w w  w  .ja  va2  s .com*/
        }
        return true;
    }

    public static <T> boolean equals(List<List<T>> lists1, List<List<T>> lists2) {
        for (List<T> list1 : lists1) {
            if (!lists2.contains(list1)) {
                return false;
            }
        }
        return true;
    }

    public static boolean contains(int[] subject, int[][] list) {
        for (int[] row : list) {
            if (Arrays.equals(subject, row)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. equals(double[][] xs, double[][] ys)
  2. equals(final byte[] a, final byte[] b)
  3. equals(final byte[] array1, final byte[] array2)
  4. equals(final T[][] a, final T[][] b)
  5. equals(int[] a, int[] b)
  6. equals(long[] a, long[] a2)
  7. equals(Map a, Map b)
  8. equals(Map map1, Map map2)
  9. equals(Object array1, Object array2)