Arrays.equals(double[], double[]) in Java

Arrays.equals(double[], double[]): This method is available in java.util.Arrays class of Java.

Syntax:

boolean java.util.Arrays.equals(double[] a, double[] a2)

This method takes two arguments of type double array as its parameters. This method returns true if the two specified arrays of doubles are equal to one another.

Parameters: Two parameters are required for this method.

a: one array to be tested for equality.

a2: the other array to be tested for equality.

Returns: true if the two arrays are equal.

Exceptions: NA

Approach

Java

import java.util.Arrays;

public class Arraysequalsdouble {
    public static void main(String[] args) {

        double a1[] = { 1091.999, 29191.991 };
        double a2[] = { 1091.999, 29191.991 };
        System.out.println(Arrays.equals(a1, a2));
    }
}

Output:

true


No comments:

Post a Comment