Answer:
import java.util.Scanner;
public class StrictlyIdentical
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] list1 = new int[5];
int[] list2 = new int[5];
System.out.println("Enter the numbers for list1: ");
for (int i=0; i<5; i++) {
list1[i] = input.nextInt();
}
System.out.println("Enter the numbers for list2: ");
for (int i=0; i<5; i++) {
list2[i] = input.nextInt();
}
if (equals(list1, list2))
System.out.println("the lists are strictly identical.");
else
System.out.println("the two lists are not strictly identical.");
}
public static boolean equals(int[] array1, int[] array2) {
boolean isIdentical = true;
for (int i=0; i<5; i++) {
if (array1[i] != array2[i])
isIdentical = false;
}
return isIdentical;
}
}
Step-by-step explanation:
Create a function called equals that takes two parameters, array1, and array2
Initialize the isIdentical as true, this will be our control variable to change its value if two arrays are not identical
Create a for loop that iterates through the arrays. If corresponding elements of the arrays are not equal, set isIdentical as false.
When the loop is done, return the isIdentical
Inside the main:
Declare two arrays
Ask the user to enter numbers for the arrays using for loop
Check if two arrays are identical using the equal function. Print the appropriate message