Question: Write a class called CommonElements with a single method main that will: Create and obtain two integer arrays (arrayA and arrayB) using RandomIntegerArrayCreator type objects

Write a class called CommonElements with a single method main that will:

Create and obtain two integer arrays (arrayA and arrayB) using RandomIntegerArrayCreator type objects and its methods, find the number of common elements between arrayA and arrayB (say: if integer 2 appears in arrayA once and twice in arrayB, that counts as ONE common element between the two),

Constraints / notes: All array elements are integers from the the set {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and can appear multiple times in each array, Arrays A and B do NOT have to be of the same size, Arrays A and B CAN be empty (no elements), Arrays A and B will NOT be sorted.

The code that I have already created:

import java.util.Random; public class RandomIntegerArrayCreator { int[] arr; RandomIntegerArrayCreator(){ Random rand =

import java.util.Random; public class RandomIntegerArrayCreator { int[] arr; RandomIntegerArrayCreator(){ Random rand = new Random(); int size - rand.nextInt (16); arr = new int[size]; for (int i=0;i

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To complete the task we need to create a new class named CommonElements and implement the logic to find the number of common elements between two arra... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!