当前位置:网站首页>Four functional interfaces
Four functional interfaces
2022-08-11 05:17:00 【Tonal 6】
函数式接口
定义:有且仅有一个方法
优点:The programming model can be simplified,The bottom layer applies a lot of these
例:以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("already entered this method");
return "already entered this method";
};
supplier.get();

边栏推荐
- FPGA engineer interview questions collection 121~130
- 代理模式(简要介绍)
- Switch and Router Technology-34-Dynamic NAT
- Idea提升工作效率的必备技巧
- MyEclipse数据库工具使用教程:使用驱动程序
- Golden Warehouse Database KingbaseGIS User Manual (6.8. Geometry Object Input Function)
- Redis详解
- 智能指针笔记
- 交换机和路由器技术-27-OSPF路由重分发
- Switch and Router Technology-31-Extended ACL
猜你喜欢
![ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx](/img/02/3896b29a955ae84a0f0326f0d2cabf.png)
ERROR: Could not install packages due to an OSError: [Errno 2] 没有那个文件或目录: ‘/data/xxxx

Switch and Router Technology - 25 - OSPF Multi-Area Configuration

MySQL must know and must know (primary articles)

Switches and routers technologies - 30 - standard acls

How to use svg-icon (svg-sprite-loader plugin)

Paper Notes: Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks

C statement: data storage

Zabbix builds enterprise-level monitoring and alarm platform

Switch and Router Technology-35-NAT to PAT

每周推荐短视频:你常用的拍立淘,它的前身原来是这样的!
随机推荐
金仓数据库 KingbaseGIS 使用手册(6.8. 几何对象输入函数)
MFC Interprocess Communication (Shared Memory)
Kong实现禁止国外IP访问
ESP8266 教程3 — 通过TCP组建局域网并通信
交换机和路由器技术-34-动态NAT
Switch and Router Technology - 28 - NSSA Areas for OSPF
【嵌入式开源库】cJSON的使用,高效精简的json解析库
交换机和路由器技术-22/23-OSPF动态路由协议/链路状态同步过程
Optimization is a kind of habit low starting point is the "standing near the critical"
Weekly recommended short video: your commonly used Polaroid, its predecessor turned out to be like this!
网络技能树
How to switch Green Shield encryption to IP-Guard encryption smoothly
How to read a paper
Project Practice Lecture 27: Application of Status Mode in Duplicate Brands
Development Tools Lecture 7: Alibaba Cloud Log Query and Analysis
在 关闭页面/卸载(unload)文档 之前向服务器发送请求
[No 2022 Shanghai Security Officer A Certificate Exam Question Bank and Mock Exam
交换机和路由器技术-36-端口镜像
【无标题】2022年胺基化工艺考试题模拟考试题库及在线模拟考试
BGP综合实验