java8-function源码

来源:互联网 发布:软件著作权代办 编辑:程序博客网 时间:2024/06/13 13:05
@FunctionalInterfacepublic interface Function<T, R> {   R apply(T t);   default <V> Function<T, V> andThen(Function<? super R, ? extends V> after) {        Objects.requireNonNull(after);        return (T t) -> after.apply(apply(t));    }    static <T> Function<T, T> identity() {        return t -> t;    }}

function中有一个apply方法

有返回值,有输入参数:R apply(T t)

用法:
Function<String, String> f = (str) -> str.toUpperCase();f.apply("lelonta");
function中被default和static修饰的都不符合函数式接口的方法
原创粉丝点击