Java Arrays.equals(boolean[] a, boolean[] a2)

Syntax

Arrays.equals(boolean[] a, boolean[] a2) has the following syntax.

public static boolean equals(boolean[] a,  boolean[] a2)

Example

In the following code shows how to use Arrays.equals(boolean[] a, boolean[] a2) method.


//from www . j a va 2 s.  c o m

import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    
    // initializing three boolean arrays
    boolean[] arr1 = new boolean[] { true, false, true };
    boolean[] arr2 = new boolean[] { false, true, true };
    boolean[] arr3 = new boolean[] { true, false, true };
    
    // comparing arr1 and arr2
    System.out.println(Arrays.equals(arr1, arr2));
    System.out.println(Arrays.equals(arr1, arr3));
  }
}

The code above generates the following result.