当前位置:网站首页>Lambda终结操作查找与匹配findFirst
Lambda终结操作查找与匹配findFirst
2022-06-13 03:35:00 【Leon_Jinhai_Sun】
findFirst
获取流中的第一个元素。
例子:
获取一个年龄最小的作家,并输出他的姓名。
// 获取一个年龄最小的作家,并输出他的姓名。
List<Author> authors = getAuthors();
Optional<Author> first = authors.stream()
.sorted((o1, o2) -> o1.getAge() - o2.getAge())
.findFirst();
first.ifPresent(author -> System.out.println(author.getName()));
边栏推荐
- Three ways of scala string interpolation
- LVS四层负载均衡集群(6)LVS工作模式
- Yolov5 face+tensorrt: deployment based on win10+tensorrt8.2+vs2019
- 【测试开发】自动化测试selenium(三)——unittest框架解析
- C语言程序设计——从键盘任意输入一个字符串,计算其实际字符个数并打印输出,要求不能使用字符串处理函数strlen(),使用自定义子函数Mystrlen()实现计算字符个数的功能。
- Data of all bank outlets in 356 cities nationwide (as of February 13, 2022)
- [test development] automatic test selenium (I)
- Tencent cloud instant messaging IM
- Getting started with Oracle
- SQL injection case demonstration and preventive measures
猜你喜欢
[test development] automated test selenium (III) -- unittest framework analysis
Workflow of driver of spark kernel (stage division, task division, task scheduling)
Spark optimization - Troubleshooting
(九)详解广播机制
Simulink code generation: simple state machine and its code
Spark optimization - Performance (general performance, operator, shuffle, JVM) tuning
Panel data set of rural cities and towns: per capita consumption and expenditure of prefecture level cities 2012-2019 & rural data of provinces 2013-2019
Onnx+tensorrt+yolov5: yolov5 deployment based on trt+onnx 1
[azure data platform] ETL tool (9) -- ADF performance optimization case sharing (1)
在JDBC连接数据库时报错:Connection to 139.9.130.37:15400 refused.
随机推荐
MySQL learning summary 9: non empty constraints, uniqueness constraints, primary key, auto_ Increment, foreign key, default, etc
MySQL learning summary 8: addition, deletion and modification of data processing
LVS四层负载均衡集群(5)LVS概述
Get to know druid IO real time OLAP data analysis storage system
Simulink代码生成: 简单状态机及其代码
Triggers & built-in packages
Detailed explanation of MySQL storage process
Doris' table creation and data division
Tencent cloud instant messaging IM
【测试开发】自动化测试selenium(三)——unittest框架解析
Express 100
【Web】Cookie 和 Session
SQL injection case demonstration and preventive measures
LVS four layer load balancing cluster (4) main methods of load balancing
Review the first three IO streams
Wechat payment configuration
Economic panel topic 1: panel data of all districts and counties in China - more than 70 indicators such as population, pollution and agriculture (2000-2019)
Cross border M & a database: SDC cross border database, Thomson database, A-share listed company M & a database and other multi index data (4w+)
Peking University HP financial index - matching enterprise green innovation index 2011-2020: enterprise name, year, industry classification and other multi indicator data
[azure data platform] ETL tool (8) - ADF dataset and link service