Question: Write in Java, 2. (7 pts) Suppose that you and I are friends on social media, and you want to figure out the friends we

Write in Java,Write in Java, 2. (7 pts) Suppose that you and I are

2. (7 pts) Suppose that you and I are friends on social media, and you want to figure out the friends we have in common. One way of doing this would be to treat your friends list as an array and my friends list as another array. Then, the problem of finding our common friends would be solvable by finding the intersection (set of common elements) between those two arrays. Assume that each friend is represented by a unique numerical ID number. Using a person's name directly isn't a good idea, because it's possible for more than one person to have the same name. Within a new class named ArrayIntersection, write a method void intersection(int[] al, int[] a2) that takes two int arrays of ID numbers as parameters. The method should find and display the intersection between those two arrays. The method should also find and display the count of common elements between the two arrays. You can assume that both arrays contain unique elements that is, neither array contains duplicate elements within itself. Hint: For each element of al, perform a linear search of a2. Note the void return type this method does not need to return anything. Just have it print the intersection and the quantity of elements in that intersection. Test your intersection method by calling it from a main method (within the same ArrayIntersection class). You do not need to get any user input just create your test arrays directly within your main method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!