b Complete the method filter which accepts two collections o

b. Complete the method filter which accepts two collections of integers, one set of input integers (numbers) and one set of integers (illegal) that should be removed from the list. Your method should use the find method above.

(DO NOT use the removeAll method on ArrayList.)

public static ArrayList<Integer> filter(

ArrayList<Integer> numbers,

ArrayList<Integer> illegal) {

Solution

public static ArrayList<Integer> filter(ArrayList<Integer> numbers, ArrayList<Integer> illegal)
{

for(int temp:illegal)
{
if(numbers.compare(temp))
   number.remove(temp);

}

}

I did not understand where to use the find method. the question said to use the find method above which was not clear. But the above specified method works for removing an element from the number list which is also present in the illegal list.

for further queries kindly get back

b. Complete the method filter which accepts two collections of integers, one set of input integers (numbers) and one set of integers (illegal) that should be re

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site