I want to filter a java.util.Collection
based on a predicate.
How about some plain and straighforward Java
List list ...;
List newList = new ArrayList<>();
for (Customer c : list){
if (c.getName().equals("dd")) newList.add(c);
}
Simple, readable and easy (and works in Android!) But if you're using Java 8 you can do it in a sweet one line:
List newList = list.stream().filter(c -> c.getName().equals("dd")).collect(toList());
Note that toList() is statically imported