1 2 3 4 5 6 7 8 9 10 11 12 | public class HighOrderFunctions { private static <T> Predicate<T> notEqual(T t) { return (v) -> !Objects.equals(v, t); } public static void main(String[] args) { List.of(1, 2, 3) .stream() .filter(notEqual(1)) .forEach(System.out::println); } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |