Compare Two int Arrays in Java
Description
The following code shows how to compare Two int Arrays.
Example
/*ww w.java2s . com*/
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] a1 = new int[] { 2, 7, 1 };
int[] a2 = new int[] { 2, 7, 1 };
System.out.println(Arrays.equals(a1, a2));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »