Java Collection Tutorial - Java Arrays.equals(long[] a, long[] a2)








Syntax

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

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

Example

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

//from w w w . j  a  v a2 s.  c  om
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    long[] arr1 = new long[] { 1, 23, 12, 45, 54 };
    long[] arr2 = new long[] { 1, 23, 12, 45, 54, 67, 78 };
    long[] arr3 = new long[] { 1, 23, 12, 45, 54, 67, 78 };
    
    System.out.println(Arrays.equals(arr1, arr2));

    System.out.println(Arrays.equals(arr2, arr3));
  }
}

The code above generates the following result.