:
public static <T> List<T> filter(final List<T> orig, final Predicate<T> pred) {
return new ArrayList<T>() {{
for (T t : orig) if (pred.allow(t)) add(t);
}};
}
"" "" "" . ; "" , .
, - :
final List<Integer> numbers = Whatever.filter(origList, new Predicate<Integer>() {
public boolean allow(Integer i) {
return i != null && i.intValue() > 0;
}
});
"T" - " ".