当前位置:网站首页>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();
边栏推荐
- Idea 2021.3.3版本文件目录展开
- BGP Comprehensive Experiment
- ARM结构体系4:嵌入式硬件平台接口开发
- Switch and Router Technology - 25 - OSPF Multi-Area Configuration
- FPGA engineer interview questions collection 111~120
- Optimization is a kind of habit low starting point is the "standing near the critical"
- The shortest path out of the maze
- Do you understand how the Selenium automated testing framework works?
- Switch and Router Technology-34-Dynamic NAT
- Redis详解
猜你喜欢
随机推荐
交换机和路由器技术-22/23-OSPF动态路由协议/链路状态同步过程
[E-commerce operation] How to formulate a social media marketing strategy?
元宇宙社交应用,靠什么吸引用户「为爱发电」?
批量修改数据库等视频文件名称
Paper Notes: Bag of Tricks for Long-Tailed Visual Recognition with Deep Convolutional Neural Networks
Smart Pointer Notes
async(异步)和await的使用
2022年质量员-土建方向-通用基础(质量员)考试模拟100题及在线模拟考试
IDEA中配置checkstyle
一个月闭关直接面进大厂,这份Android面试笔记是真的牛逼
K8s复习笔记7--Redis单机和Redis-cluster的K8S实现
BGP综合实验
Switches and routers technology - 24 - configure OSPF single area
2022年Android面试中最常问的问题是什么?
分库分表ShardingSphere-JDBC笔记整理
绿盾加密如何顺利切换成IP-Guard加密
你务必得明白——JSP的九大内置对象与四大域对象
[FPGA tutorial case 49] Control case 1 - FPGA-based PID controller verilog implementation
The shortest path out of the maze
C语言题解:谁是凶手!