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

Syntax

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

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

Example

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


/*from w ww  . j  a v  a  2  s . c  o  m*/

import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    
    char[] arr1 = new char[] { 'x', 'y', 'b', 'a' };
    char[] arr2 = new char[] { 'y', 'x', 'a', 'b','z' };
    char[] arr3 = new char[] { 'x', 'y', 'b', 'a' };
    
    
    System.out.println(Arrays.equals(arr1, arr2));

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

The code above generates the following result.