当前位置:网站首页>Lambda intermediate operation flatmap
Lambda intermediate operation flatmap
2022-06-12 00:43:00 【Leon_ Jinhai_ Sun】
flatMap
map Only one object can be converted into another object as an element in the stream . and flatMap You can convert an object into multiple objects as elements in the stream .
Patients with a :
Print the names of all books . Require duplicate elements to be de duplicated .
// Print the names of all books . Require duplicate elements to be de duplicated .
List<Author> authors = getAuthors();
authors.stream()
.flatMap(author -> author.getBooks().stream())
.distinct()
.forEach(book -> System.out.println(book.getName()));Example 2 :
Print all categories of existing data . De duplication of classification is required . This format cannot appear : philosophy , love
// Print all categories of existing data . De duplication of classification is required . This format cannot appear : philosophy , love love
List<Author> authors = getAuthors();
authors.stream()
.flatMap(author -> author.getBooks().stream())
.distinct()
.flatMap(book -> Arrays.stream(book.getCategory().split(",")))
.distinct()
.forEach(category-> System.out.println(category));边栏推荐
- 1、 Getting started with flutter learn to write a simple client
- C language structure - learning 27
- Anfulai embedded weekly report (issue 254): February 21, 2022 to February 27, 2022
- How to optimize plantuml flow diagram (sequence diagram)
- Dry goods | what do testers need to do for a complete performance test?
- "Failure" of the prospectus of Laowang: Laowang made its first dash for listing in Hong Kong, and the turnover rate continued to decline
- Lambda中间操作filter
- Recurrent+Transformer 视频恢复领域的‘德艺双馨’
- Construction environnementale 2
- C language multidimensional array and pointer - learning 24
猜你喜欢

Month selector disable data after the current month to include the current month

Environment construction 2

What is bonded warehouse and what is the difference between them

Matplotlip basic drawing learning of data analysis - 01

Dry goods | what do testers need to do for a complete performance test?

Characteristics of JS logical operators

How to send Apple phone WPS files to QQ mailbox

Enterprise wechat H5_ Integrated message decryption class, message push get and post callback processing

win10文件夹状态红叉表示的是什么

UVM: transaction level modeling (TLM) 1.0 communication standard
随机推荐
Lambda快速入门
Mysql database: introduction to database 𞓜 addition, deletion, modification and query
Zhangxiaobai takes you to install MySQL 5.7 on Huawei cloud ECS server
System.CommandLine选项Option
LabVIEW Arduino电子称重系统(项目篇—1)
R language spline curve piecewise linear regression model piecewise regression estimation of individual stock beta value analysis of yield data
出门带着小溪
Lambda中间操作map
Scope and category of C language variables - learning 20
What is bonded warehouse and what is the difference between them
At the digital data nextionbi online conference, traditional enterprises showed their in-depth understanding of data analysis
How to measure the app project? How to build a test system
Anfulai embedded weekly report (issue 254): February 21, 2022 to February 27, 2022
Experiment 6 constructor + copy construction
Jiaming's day13 of C learning -- structure and structure pointer
Redis advanced - correspondence between object and code base
[case] building a universal data lake for Fuguo fund based on star ring technology data cloud platform TDC
Experiment four categories and objects
Flutter uses local pictures
[answer] business use cases and system use cases are mixed together