当前位置:网站首页>四大函数式接口
四大函数式接口
2022-08-11 05:09:00 【念奴娇6】
函数式接口
定义:有且仅有一个方法
优点:可以简化编程模型,底层大量应用这些
例:以Runnable为例
1.函数型接口
示例:
Function function=(str)->{
return str;
};
System.out.println(function.apply("asd"));
2.断定型接口
示例:
Predicate<List> predicate=(p)->{
if (p.isEmpty()){
return true;
}
return false;
};//若List为空,则返回true,否则返回false;
System.out.println(predicate.test(new ArrayList()));
3.消费型接口
示例:
Consumer<Integer> consumer=(i)->{
i=i+1;
};
consumer.accept(8);
结果:
4.供给型接口
示例:
Supplier supplier=()->{
System.out.println("已经入此方法");
return "已经入此方法";
};
supplier.get();
边栏推荐
- ALSA音频架构
- FPGA工程师面试试题集锦111~120
- 交换机和路由器技术-32-命名ACL
- MFC Interprocess Communication (Shared Memory)
- ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx
- 项目实战第二十七讲:状态模式在重名品牌中的应用
- Network Skill Tree
- async(异步)和await的使用
- Project Practice Lecture 27: Application of Status Mode in Duplicate Brands
- 元宇宙社交应用,靠什么吸引用户「为爱发电」?
猜你喜欢
Internet Protocol 1
交换机和路由器技术-29-OSPF虚链路
zabbix构建企业级监控告警平台
CAD2020 打开错误报告 e06d7363h Exception at 13644F69h
CAN/以太网转换器 CAN与以太网互联互通
Paper Notes: BBN: Bilateral-Branch Network with Cumulative Learning for Long-Tailed Visual Recognition
ESP8266 教程3 — 通过TCP组建局域网并通信
Application layer protocol - DNS
C Language: Practical Debugging Tips
findViewById返回null的问题
随机推荐
Let's talk programming languages together
02.折叠隐藏文字
About CC Attacks
findViewById返回null的问题
交换机和路由器技术-22/23-OSPF动态路由协议/链路状态同步过程
[QNX Hypervisor 2.2 User Manual] 10.16 vdev virtio-blk
Summary of c language fprintf, fscanf, sscanf and sprintf function knowledge points
嵌入式分享合集33
CAD2020 打开错误报告 e06d7363h Exception at 13644F69h
ALSA音频架构 -- snd_pcm_open函数分析
MFC Interprocess Communication (Shared Memory)
HAVE FUN | "SOFA Planet" spacecraft plan, the latest progress of source code analysis activities
分层架构&SOA架构
【FPGA教程案例50】控制案例2——基于FPGA的PD控制器verilog实现
交换机和路由器技术-29-OSPF虚链路
Switch and Router Technology-31-Extended ACL
form表单提交数据库中文变成问号
绿盾加密如何顺利切换成IP-Guard加密
交换机和路由器技术-24-OSPF单区域配置
Thymeleaf