Question: This is m RandomIntegerArrayCreator: import java.util.*; class RandomIntegerArrayCreator{ int [] arr; RandomIntegerArrayCreator(){ Random r = new Random(); int size = r.nextInt(16); arr = new int[size];
This is m RandomIntegerArrayCreator:
import java.util.*;
class RandomIntegerArrayCreator{ int [] arr; RandomIntegerArrayCreator(){ Random r = new Random(); int size = r.nextInt(16); arr = new int[size]; for (int i=0; i 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), display the result using the format shown below (see Sample Output box). Sample Output: Array A: 2 3 1 0 1 5 Array B: 4 3 4 0 5 2 1 2 2 5 Element: # in A: # in B: 0 1 1 1 2 1 2 1 3 3 1 1 5 1 2 If there are no common elements (or one or two arrays are empty), just display: Number of common elements in A and B: 0 Number of common elements in A and B: 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
