Java Arrays.equals(int[] a, int[] a2)
Syntax
Arrays.equals(int[] a, int[] a2) has the following syntax.
public static boolean equals(int[] a, int[] a2)
Example
In the following code shows how to use Arrays.equals(int[] a, int[] a2) method.
//from ww w. j a v a 2 s .co m
import java.util.Arrays;
public class Main {
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));
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »