1、Predicate是布尔型函数,只有一个输入参数。Predicate接口包含多种默认方法来处理复杂的逻辑动词。
Predicatepredicate = (s) -> s.length() > 0; predicate.test("foo"); // true predicate.negate().test("foo"); // false Predicate nonNull = Objects::nonNull; Predicate isNull = Objects::isNull; Predicate isEmpty = String::isEmpty; Predicate isNotEmpty = isEmpty.negate();
2、Function接口接收一个参数并返回单个结果。默认情况下,多个函数可以串联在一起。
FunctiontoInteger = Integer::valueOf; Function backToString = toInteger.andThen(String::valueOf); backToString.apply("123"); // "123"
3、Supplier接口产生给定类型的结果。不像Function,Supplier没有输入参数。
SupplierpersonSupplier = Person::new; personSupplier.get(); // new Person











