博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java8(2)函数式接口
阅读量:7209 次
发布时间:2019-06-29

本文共 1342 字,大约阅读时间需要 4 分钟。

hot3.png

函数式接口

就是只定义一个抽象方法(用来表示行为)的接口,用作Lambda表达式的类型。

public interface Comparator
{ 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

原始类型特化
Predicate
IntPredicate
LongPredicate
DoublePredicate
Consumer
IntConsumer
LongConsumer
DoubleConsumer
Function<T,R>
IntFunction<R>,
IntToDoubleFunction,
IntToLongFunction,
LongFunction<R>,
LongToDoubleFunction,
LongToIntFunction,
DoubleFunction<R>,
ToIntFunction<T>,
ToDoubleFunction<T>,
ToLongFunction<T>
Supplier<T>
BooleanSupplier
IntSupplier
LongSupplier
DoubleSupplier
UnaryOperator<T>
IntUnaryOperator
LongUnaryOperator
DoubleUnaryOperator
BinaryOperator<T>
IntBinaryOperator
LongBinaryOperator
DoubleBinaryOperator
BiConsumer<T,U>
ObjIntConsumer<T>
ObjLongConsumer<T>
ObjDoubleConsumer<T>
BiFunction<T,U,R>
ToIntBiFunction<T,U>
ToLongBiFunction<T,U>
ToDoubleBiFunction<T,U>

转载于:https://my.oschina.net/u/563488/blog/1621122

你可能感兴趣的文章
selenium之调用js解决淘宝点击下一页问题(JAVA版)
查看>>
flask安装及第一个程序
查看>>
C++中const限定符的应用
查看>>
Eclipse开启Mybatis-config.xml配置文件智能提示
查看>>
微服务框架Dubbo--SpringCloud区别
查看>>
我知道的泛型
查看>>
iOS MVVM设计模式
查看>>
JavaWEB之Jsp基础知识总结_慕课手记
查看>>
JQuery未来元素事件监听写法
查看>>
lucene 结合数据库做搜索
查看>>
题解 CF1051F 【The Shortest Statement】
查看>>
静态代理与动态代理(JDK代理/cglib代理)的区别
查看>>
VC中全局变量初始化方法
查看>>
mac 字幕生成工具
查看>>
hadoop 常用命令行操作小结
查看>>
Mysql错误:ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
查看>>
[MST][dij]JZOJ 5818 做运动
查看>>
[SPFA]JZOJ 5869 绿洲
查看>>
SharePoint 更新文档库文档标题(Title)字段
查看>>
python拓展2 collections模块与string模块
查看>>