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.


//from  w  w w . j  av a2 s . c  o  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.