/* Maryam Shaheen #1140427 */ import java.util.Arrays; public class Task_3 { private static java.util.Scanner input; public static void main(String [] args) { input = new java.util.Scanner(System.in);// Scanner int i; // defining the variable i System.out.print("Enter list1: "); // printing statement int size1 = input.nextInt(); //scanning the size of the first array int[] list1 = new int[size1]; // defining the first array for ( i = 0; i < list1.length; i++) { //A loop for filling the first array list1[i] = input.nextInt(); } System.out.print("Enter list2: ");//printing statement int size2 = input.nextInt();// scanning the size of the second array int[] list2 = new int[size2];// defining the second array for ( i = 0; i < list2.length; i++) {// A loop for filling the second array list2[i] = input.nextInt(); } if (equals(list1, list2)) { System.out.println("Two lists are identical");//printing statement } else { System.out.println("Two lists are not identical");//printing statement } } public static boolean equals(int[] list1, int[] list2) {// checking if the two arrays are equal int i; if(list1.length == list2.length) {//if the size of array1 equals to the size of array2 then >>> Arrays.sort(list1);// sort the first array Arrays.sort(list2);// sort the second array } else// if their sizes are not equal then return false return false; for ( i = 0; i < list1.length; i++) {// A for loop to check whether the elements in the two arrays are equalized if (list1[i] != list2[i]) {// if the two element in the same indexes in the two arrays are not equalized then return false return false; } } //if the two element in the same indexes in the two arrays are equalized then return true return true; } }