Tests two arrays for equality.
import java.util.Arrays;
class Main{
/**
* Tests two arrays for equality. To be considered equal, the arrays must
* have exactly the same dimensions, and the values in each array must also
* match (two values that qre both NaN or both INF are considered equal
* in this test).
*
* @param a the first array (<code>null</code> permitted).
* @param b the second array (<code>null</code> permitted).
*
* @return A boolean.
*
* @since JFreeChart 1.0.13
*/
public static boolean equal(double[][] a, double[][] b) {
if (a == null) {
return (b == null);
}
if (b == null) {
return false; // already know 'a' isn't null
}
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;
}
}
Related examples in the same category