java8(2)函数式接口
函数式接口 就是只定义一个抽象方法(用来表示 行为 )的接口,用作Lambda表达式的类型。 public interface Comparator<T> { int compare(T o1, T o2); } public interface Runnable{ void run(); } java.util.function中给到的部分函数式接口 函数式接口 函数描述符 方法 default方法 Predicate<T> T->boolean test(T t) and,negate,or,isEqual Consumer<T> T->void accept(T t) andThen Function<T,R> T->R apply(T t) compose,andThen,identity Supplier<T> ()->T get() 无 BiPredicate<L,R> (L,R)->boolean test(L l, R r) and,negate,or BiConsumer<T,U> (T,U)->void accept(T t, U u) andThen BiFunction<T,U,R> (T,U)->R apply(T t, U u) andThen UnaryOperator<T> T->T BinaryOperator<T> (T,T)->T 原始类型特化