当前位置:网站首页>Lambda end operation collect
Lambda end operation collect
2022-06-13 03:48:00 【Leon_ Jinhai_ Sun】
collect
Convert the current stream into a collection .
Example :
Get a file that holds the names of all authors List aggregate .
// Get a file that holds the names of all authors List aggregate .
List<Author> authors = getAuthors();
List<String> nameList = authors.stream()
.map(author -> author.getName())
.collect(Collectors.toList());
System.out.println(nameList);Get a list of all book titles Set aggregate .
// Get a list of all book titles Set aggregate .
List<Author> authors = getAuthors();
Set<Book> books = authors.stream()
.flatMap(author -> author.getBooks().stream())
.collect(Collectors.toSet());
System.out.println(books);Get one Map aggregate ,map Of key Name the author ,value by List<Book>
// Get one Map aggregate ,map Of key Name the author ,value by List<Book>
List<Author> authors = getAuthors();
Map<String, List<Book>> map = authors.stream()
.distinct()
.collect(Collectors.toMap(author -> author.getName(), author -> author.getBooks()));
System.out.println(map);边栏推荐
- Installing MySQL 8.0.20 under Linux and ubuntu20.04 LTS
- 单片机:EEPROM介绍与操作
- LVS四层负载均衡集群(4)负载均衡的主要方式
- Application scenarios of large arrows in Scala
- 【愚公系列】2022年06月 .NET架构班 080-分布式中间件 ScheduleMaster的Master集群和数据库切换
- 单片机:Modbus 多机通信程序设计
- Field * doesn't have a default value problem
- 【测试开发】博客系统——Loadrunner性能测试(发布博客功能 基准测试)
- Multithreaded chat room, server and client
- Workflow of driver of spark kernel (stage division, task division, task scheduling)
猜你喜欢

Doris data backup and recovery

MapReduce internal execution principle

单片机:RS485 通信与 Modbus 协议

LVS四層負載均衡集群(5)LVS概述

Synching build your own synchronization cloud

Very simple installation and configuration of nodejs

【测试开发】博客系统——Loadrunner性能测试(发布博客功能 基准测试)

Get to know druid IO real time OLAP data analysis storage system

四旋翼飞行器避障系统基础

【测试开发】用例篇
随机推荐
Watering artifact based on Huawei cloud Internet of things (stm32+esp8266)
Multi thread implementation of selling tickets and producers and consumers
Simulink code generation: simple state machine and its code
单片机:PCF8591硬件接口
USB-IF BC1.2充电协议解读
Oracle built-in functions
SQL injection case demonstration and preventive measures
LVS four layer load balancing cluster (4) main methods of load balancing
[test development] automated test selenium (III) -- unittest framework analysis
Tencent cloud instant messaging IM
Time complexity
How much can I get after the insurance period of annuity insurance products expires?
Alipay open platform
Meaning of different values of margin and padding
微信扫描二维码无法下载文件的解决办法
IP address and classification
LeetCode 178. Score ranking (MySQL)
Lambda终结操作查找与匹配noneMatch
测试写入mysql数据300W条,每次1.6-2W之间就断掉然后出现以下问题:
LVS four - tier Load Balancing Cluster (5) LVS Overview