Question: Question 02 : Write a Java main method that calls a method readArray two times to read integer values in two integer arrays each of
Question 02: Write a Java main method that calls a method readArray two times to read integer values in two integer arrays each of size input in the readArray method. Your readArray method must validate the size of an array by looping until a size that is not negative is entered. Assume that there are no InputMismatchExceptions and that values read in each array are distinct [i.e., in each array there are no duplicate values. DONT TEST FOR THIS]. The main method then passes the two array references to a method getSetIntersection which returns a reference to an integer array that contains the intersection of the two arrays. The main method finally displays the intersection.
Note:
Your program must be general.
The returned set intersection must have distinct elements.
The method getSetIntersection must not contain calls to input or output methods.
The behaviour of your program must be similar to the program runs below:

Enter array size: -2 Error: invalid array size. Enter array size: -4 Error: invalid array size. Enter array size: 4 Enter element#1 : 1 Enter element#2: Enter element# 3: 3 Enter element#4 Enter array size: 4 Enter element#1: Enter element#2: Enter element# 3: 3 Enter element#4: 1 The intersection is: t 1, 2, 3, 4 1h
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
