Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * <p>Compare two double arrays and return true if both not null, and are of equal length and contain equal values.</p>
     *
     * @param   a1
     * @param   a2
     * @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;
    }
}