import java.util.Arrays;
public class Main {
public static void main(String[] args) throws Exception {
int[] ary1 = {1,2,3,4,5,6};
int[] ary2 = {1,2,3,4,5,6};
int[] ary3 = {1,2,3,4};
System.out.println("Is array 1 equal to array 2?? "
+Arrays.equals(ary, ary1));
System.out.println("Is array 1 equal to array 3?? "
+Arrays.equals(ary, ary2));
}
}
output:
Is array 1 equal to array 2?? true
Is array 1 equal to array 3?? false
public class Main {
public static void main(String[] args) throws Exception {
int[] ary1 = {1,2,3,4,5,6};
int[] ary2 = {1,2,3,4,5,6};
int[] ary3 = {1,2,3,4};
System.out.println("Is array 1 equal to array 2?? "
+Arrays.equals(ary, ary1));
System.out.println("Is array 1 equal to array 3?? "
+Arrays.equals(ary, ary2));
}
}
output:
Is array 1 equal to array 2?? true
Is array 1 equal to array 3?? false