Java Collection Tutorial - Java Arrays.deepEquals(Object [] a1, Object [] a2)








Syntax

Arrays.deepEquals(Object [] a1, Object [] a2) has the following syntax.

public static boolean deepEquals(Object [] a1,   Object [] a2)

Example

In the following code shows how to use Arrays.deepEquals(Object [] a1, Object [] a2) method.

//from  ww w  .  j a va  2s. c o m
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    Object[] b1 = new Object[] { 'a', 'b' };
    Object[] b2 = new Object[] { 'a', 'b' };
    Object[] b3 = new Object[] { 'x', 'y' };

    System.out.println(Arrays.deepEquals(b1,b2));
    
    System.out.println(Arrays.deepEquals(b1,b3));  
  }
}

The code above generates the following result.