Question: Write a program named CommonElements that prompts the user to enter two arrays of integers , saves the common elements that appear in both arrays
Write a program named CommonElements that prompts the user to enter two arrays of integers, saves the common elements that appear in both arrays in an ArrayList and displays the contents of the ArrayList. Note that the first number in the input indicates the number of the elements in the array. This number is not part of the array. Here are several sample run:
Enter list1: 5 5 10 2 1 6
Enter list2: 9 2 3 10 3 34 35 67 3 1
The common elements are 10 2 1
Enter list1: 7 1 2 3 4 5 6 7
Enter list2: 5 10 11 12 13 14 15
There are no common elements
Make sure the program follows the Java Coding Guidelines with comments documenting the codes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
