Java Array Equal equals(double[][] xs, double[][] ys)

Here you can find the source of equals(double[][] xs, double[][] ys)

Description

Tests two double[][] arrays for having equal contents.

License

Open Source License

Return

true iff for each i, equals(xs[i],ys[i]) is true

Declaration

public static boolean equals(double[][] xs, double[][] ys) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**//from   w  w w  .  j ava  2  s.  c o  m
     * Tests two double[][] arrays for having equal contents.
     * @return true iff for each i, <code>equals(xs[i],ys[i])</code> is true
     */
    public static boolean equals(double[][] xs, double[][] ys) {
        if (xs == null)
            return ys == null;
        if (ys == null)
            return false;
        if (xs.length != ys.length)
            return false;
        for (int i = xs.length - 1; i >= 0; i--) {
            if (!Arrays.equals(xs[i], ys[i]))
                return false;
        }
        return true;
    }

    /**
     * Tests two boolean[][] arrays for having equal contents.
     * @return true iff for each i, <code>Arrays.equals(xs[i],ys[i])</code> is true
     */
    @SuppressWarnings("null")
    public static boolean equals(boolean[][] xs, boolean[][] ys) {
        if (xs == null && ys != null)
            return false;
        if (ys == null)
            return false;
        if (xs.length != ys.length)
            return false;
        for (int i = xs.length - 1; i >= 0; i--) {
            if (!Arrays.equals(xs[i], ys[i]))
                return false;
        }
        return true;
    }
}

Related

  1. equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
  2. equals(char[] left, int offsetLeft, char[] right, int offsetRight, int length)
  3. equals(char[] str1, char[] str2)
  4. equals(char[][] c1, char[][] c2)
  5. equals(Collection asCollection, String[] values)
  6. equals(final byte[] a, final byte[] b)
  7. equals(final byte[] array1, final byte[] array2)
  8. equals(final T[][] a, final T[][] b)
  9. equals(int[] a, int[] b)