Illegal Numbers

Illegal numbers.

a. Complete the method find which accepts a collection of integers and a target, and returns the position that the integer is found in, or a flag of -1 if the integer is not in the collection.

(DO NOT use the indexOf method on ArrayList.)

public static int find(ArrayList numbers,

int target) {

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 filter(ArrayList numbers,ArrayList illegal) {

import java.util.ArrayList;public class Test {public static void main(String args) {}/**** Find the number in Arraylist** @param numbers* @param target* @return*/public static int…

Leave a Reply

Your email address will not be published. Required fields are marked *