Example usage for java.util Arrays equals

List of usage examples for java.util Arrays equals

Introduction

In this page you can find the example usage for java.util Arrays equals.

Prototype

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

Source Link

Document

Returns true if the two specified arrays of Objects are equal to one another.

Usage

From source file:Main.java

public static void main(String[] args) {
    long[] a1 = new long[] { 2, 8, 3 };
    long[] a2 = new long[] { 2, 8, 3 };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    byte[] a1 = new byte[] { 7, 25, 12 };
    byte[] a2 = new byte[] { 7, 25, 12 };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    short[] a1 = new short[] { 1, 3, 8 };
    short[] a2 = new short[] { 7, 3, 8 };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    double[] a1 = new double[] { 1.3, 7.2, 4.2 };

    double[] a2 = new double[] { 1.3, 7.2, 4.2 };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    float[] a1 = new float[] { 4.4f, 3.3f, 5.3f };
    float[] a2 = new float[] { 4.4f, 3.3f, 5.3f };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    char[] a1 = new char[] { 'a', 'b', 'c', 'd' };

    char[] a2 = new char[] { 'a', 'b', 'c', 'd' };

    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] args) {
    boolean[] a1 = new boolean[] { true, false, true };
    boolean[] a2 = new boolean[] { true, false, true };
    System.out.println(Arrays.equals(a1, a2));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    boolean[] bArr1 = new boolean[] { true, false };
    boolean[] bArr2 = new boolean[] { true, false };
    boolean b = Arrays.equals(bArr1, null); // false
    b = Arrays.equals(bArr1, bArr2); // true
}

From source file:Main.java

public static void main(String[] args) {
    String[] abc = { "a", "b", "c", "d" };
    String[] xyz = { "A", "b", "c", "s" };
    String[] java = { "Java", "Dot", "Com" };

    System.out.println(Arrays.equals(abc, xyz));
    System.out.println(Arrays.equals(abc, java));
}

From source file:Main.java

public static void main(String[] args) {

    int[] arr1 = new int[] { 1, 12, 5, 6 };
    int[] arr2 = new int[] { 1, 12, 5, 6 };
    int[] arr3 = new int[] { 1, 5, 6, 12 };

    System.out.println(Arrays.equals(arr1, arr2));

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