Question: Short Words Filter 1. Create an interface as follows. 2. public interface Filter { 3. boolean accept(Object x); 5. } 6. Implement a static method

 Short Words Filter 1. Create an interface as follows. 2. public

Short Words Filter 1. Create an interface as follows. 2. public interface Filter { 3. boolean accept(Object x); 5. } 6. Implement a static method in the Filter Interface applyFilter. The method would take an ArrayList of type object objects and a Filter Instance, and would return all items in the objects array that are accepted by the supplied filter. NOTE how the method parameter and return types are object so it can accept any type. 7. static ArrayList applyFilter(ArrayList objects, Filter f) 8. // loop over the array list of objects 9. // if the passed filter's accept method returns true, then add the element to the arraylist to be returned. 10. // return the filtered array list 11. 3 12. Create a class ShortWordFilter that implements the filter interface. 13. The accept method for this class should accept all string of length

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!