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








Syntax

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

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

Example

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

/*  ww w.  j a  v  a  2 s. co  m*/

import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    byte[] arr1 = new byte[] { 1, 3, 2 , 4 };
    byte[] arr2 = new byte[] { 1, 3, 2 , 4 };
    byte[] arr3 = new byte[] { 3, 4, 1 , 2 };
    
    System.out.println(Arrays.equals(arr1, arr2));
    System.out.println(Arrays.equals(arr1, arr3));
  }
}

The code above generates the following result.