当前位置:网站首页>Lambda termination operation Max & min
Lambda termination operation Max & min
2022-06-13 03:48:00 【Leon_ Jinhai_ Sun】
max&min
Can be used to or the maximum value in the stream .
Example :
Get the highest and lowest scores of the books produced by these writers respectively and print .
// Get the highest and lowest scores of the books produced by these writers respectively and print .
//Stream<Author> -> Stream<Book> ->Stream<Integer> -> evaluation
List<Author> authors = getAuthors();
Optional<Integer> max = authors.stream()
.flatMap(author -> author.getBooks().stream())
.map(book -> book.getScore())
.max((score1, score2) -> score1 - score2);
Optional<Integer> min = authors.stream()
.flatMap(author -> author.getBooks().stream())
.map(book -> book.getScore())
.min((score1, score2) -> score1 - score2);
System.out.println(max.get());
System.out.println(min.get());边栏推荐
猜你喜欢

【多线程】多线程到底是个甚——多线程初阶(复习自用)

【 développement d'essais 】 sélénium d'essais automatisés (Ⅲ) - - analyse du cadre unitest

GoFrame第四天

单片机:Modbus 通信协议介绍

【测试开发】测试管理工具禅道的安装

单片机:RS485 通信与 Modbus 协议

【测试开发】自动化测试selenium(二)——webdriver常用的API

【测试开发】测试的相关基本概念

LVS four layer load balancing cluster (5) LVS overview

Among the four common technologies for UAV obstacle avoidance, why does Dajiang prefer binocular vision
随机推荐
单片机:A/D(模数转换)的主要指标
Lambda终结操作count
【测试开发】进阶篇——各种测试技术分类
LVS four - tier Load Balancing Cluster (5) LVS Overview
Lambda终结操作查找与匹配findFirst
Oracle built-in functions
Time complexity
LVS four layer load balancing cluster (4) main methods of load balancing
Talking about the wavelength of laser radar
Doris' table creation and data division
单片机:EEPROM 多字节读写操作时序
单片机:RS485 通信与 Modbus 协议
Getting started with Oracle
Lambda end operation find and match allmatch
Three ways of scala string interpolation
【Web】Cookie 和 Session
2022春学期总结
单片机:D/A 输出
Jumpserver installation
双目视觉——打造室外避障的“最优解”