Filter a Generic List With a Checker Interface
mediumQuestion 505The generic interface Checker<T> has one method, test, that answers yes or no about a value. Write a generic method that uses any checker to pick items out of a list. The tests pass in different rules, so your method must not know what the rule is.
Requirements:
1. Inside Filter, write a public static generic method named keep with one type parameter T. It takes an ArrayList<T> named items and a Checker<T> named rule, and it returns an ArrayList<T>.
2. The returned list is a NEW list. It holds, in their original order, only the items for which rule.test(item) is true.
3. Do not change the list that was passed in.
4. Do not change the Checker interface.
Do NOT write a main method.
Expected output
[11, 15, 20] [4, 11, 8, 15, 20] [planet, galaxy]
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...