Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Program Problem Description: Two arrays are strictly identical if their cor

ID: 3938095 • Letter: J

Question

Java Program Problem Description: Two arrays are strictly identical if their corresponding elements are equal. Write a program with class name StrictlyIdentical that prompts the user to enter two lists of integers of size 5 and displays whether the two are strictly identical. Use following method header to pass two arrays and return a Boolean. public static boolean equals(int[] array1, int[] array2) Method will return true if array1 and array2 are strictly identical otherwise it will return false. Here are two sample runs: Sample 1: Enter 5 elements of list1: 23 55 31 2 10 Enter 5 elements of list2: 23 55 31 2 10 Two lists are strictly identical. Sample 2: Enter 5 elements of list1: 23 55 31 2 10 Enter 5 elements of list2: 23 55 3 2 10 Two lists are not strictly identical.

Explanation / Answer

importjava.util.Scanner;
public class StrictlyIdentical
{
public static void main(String args[])
{
int[] a=new int[5];
int[] b=new int[5];
Scanner s=new Scanner(System.in);
System.out.println("enter list 1 :");
for(int i=0;i<5;i++)
{
a[i]=s.nextInt();
}
System.out.println("enter list 2 :");
for(int i=0;i<5;i++)
{
b[i]=s.nextInt();
}
boolean flag=equals(a,b);
if(flag)
System.out.println(" two lists are strictly identical");
else
System.out.println(" two lists are not strictly identical");
}
public static boolean equals(int[] arr1,int[] arr2)
{
for(int i=0;i<5;i++)
{
if(arr1[i]!=arr2[i])
return false;
}
return false;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote