Question
please explain this Java problem with source code if possible

Project: Strictly identical arrays Problem Deseription: Two arrays are strictly identical if their correspondimg elements are
0 0
Add a comment Improve this question Transcribed image text
Answer #1

StrictlyIdentical.java

import java.util.Arrays;
import java.util.Scanner;


public class StrictlyIdentical {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       int list1[]= new int[5];
       System.out.print("Enter 5 elements of list1: ");
       for(int i=0; i<5; i++){
           list1[i] = scan.nextInt();
       }
       int list2[]= new int[5];
       System.out.print("Enter 5 elements of list2: ");
       for(int i=0; i<5; i++){
           list2[i] = scan.nextInt();
       }
       if(equals(list1, list2)){
           System.out.println("Two lists are strictly identical.");
       }
       else{
           System.out.println("Two lists are not strictly identical.");
       }
   }
   public static boolean equals(int[] array1, int[] array2){
       if(array1.length != array2.length){
           return false;
       }
       else{
           for(int i=0; i<array1.length;i++){
               if(array1[i] != array2[i]){
                   return false;
               }
           }
       }
       return true;
   }

}

Output:

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.

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.

Add a comment
Know the answer?
Add Answer to:
please explain this Java problem with source code if possible Project: Strictly identical arrays Problem Deseription:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA METHOD: Use YOUR original code - COPY AND PASTE WILL GET THUMBS DOWN Two arrays...

    JAVA METHOD: Use YOUR original code - COPY AND PASTE WILL GET THUMBS DOWN Two arrays list1 and list2 are identical if they have the same contents. Write a method that returns true if list1 and list2 are identical, using the following header:

  • Note: According to the question, please write source code in java only using the class method....

    Note: According to the question, please write source code in java only using the class method. Sample Run (output) should be the same as displayed in the question below. Make sure the source code is working properly and no errors. Exercise #2: Design and implement a program (name it compareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array...

  • Need help with java code, this is all in a method 1) 3 different arrays are...

    Need help with java code, this is all in a method 1) 3 different arrays are brought in 2) I create local array called arrayWithLargestValues which is the size of the largest array from the 3 brought in 3) I need to somehow fill the local 'arrayWithLargestValues' with the all different largest values from the 3 different arrays hopefully I made sense sample input/output int [ ] arrayWithLargestValues = new int [ ] // this has to be set to...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise #2:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns...

  • c++ please no global varaible write a value returning function input data to dynamically allocate a...

    c++ please no global varaible write a value returning function input data to dynamically allocate a short array of size elements and store the input data entered from the disk file into array.Return the base address of the array allocated.Read the data from the text file Hello.txt and store the data in reverse order in the array.the size of the data set will be in the file size 10 and the data was 1 2 3 4 5 6 7...

  • C++ Arrays & Methods

     #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns true (Boolean type) if the arrays store same values in the same order. Otherwise, it...

  • Programming in java In this part of this Lab exercise, you will need to create a...

    Programming in java In this part of this Lab exercise, you will need to create a new class named ArrayShiftMult. This class carries out simple manipulation of an array. Then you should add a main method to this class to check that your code does what it is supposed to do. 1. Create a BlueJ project named LAB06 as follows: a. Open the P drive and create a folder named Blue), if it does not exist already. Under this folder,...

  • SOLVE IN PYTHON: Exercise #2: Design and implement a program (name it CompareArrays) that compares the...

    SOLVE IN PYTHON: Exercise #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns true (Boolean type) if the arrays store same values in the...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • C++ Single Dimensional Arrays

    Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array.  The program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT