Question: a ) Write a method that returns the number of values in a given ArrayList { 1 , 3 , 5 , dots } {

a) Write a method that returns the number of values in a given ArrayList{1,3,5,dots}{0,1,2,4,5,6}> that occur in
another ArrayList. Neither ArrayList should be modified. You must use the
sort() and binarySearch() methods from the Collections class. No other method will be
accepted. Use a constructor in the ArrayList class to make a copy of the parameter to avoid
modifying the original ArrayList.
The method signature is:
public static int countCommon(ArrayList targets, ArrayList source)
For example: If the targets contained {1,3,5,dots} and source contained {0,1,2,4,5,6} then 2 would be
returned.
a ) Write a method that returns the number of

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 Programming Questions!