Here you can find the source of arraysAreEqual(double[] a1, double[] a2)
Compare two double arrays and return true if both not null, and are of equal length and contain equal values.
Parameter | Description |
---|---|
a1 | first array |
a2 | second array |
static public boolean arraysAreEqual(double[] a1, double[] a2)
//package com.java2s; public class Main { /**//ww w . j a va 2 s.co m * <p>Compare two double arrays and return true if both not null, and are of equal length and contain equal values.</p> * * @param a1 first array * @param a2 second array * @return true if equal */ static public boolean arraysAreEqual(double[] a1, double[] a2) { //System.err.println("ArrayCopyUtilities.arraysAreEqual(): a1 = "+a1); //System.err.println("ArrayCopyUtilities.arraysAreEqual(): a2 = "+a2); boolean result = true; if (a1 == null || a2 == null || a1.length != a2.length) { result = false; } else { for (int i = 0; i < a1.length; ++i) { //if (a1[i] != a2[i]) { if (Math.abs(a1[i] - a2[i]) > 0.000001) { result = false; break; } } } //System.err.println("ArrayCopyUtilities.arraysAreEqual(): "+result); return result; } }