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 = 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
Step: 1
arrA and arrB are 2 randomly generated arrays from r and ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started