当前位置:网站首页>lambda学习(sort后面的Comparator的使用,collection后使用Collectors.groupingBy分组)
lambda学习(sort后面的Comparator的使用,collection后使用Collectors.groupingBy分组)
2022-07-23 21:43:00 【进击的北极熊】
1、sort中使用Comparator.comparing 进行比较排序
var docs = docSettlements.stream().filter(m -> m.getProjectSettlementIdentifierNo().equals(item)).sorted(Comparator.comparing(DocSettlementEntity::getVersionNo).reversed()).collect(Collectors.toList());
1.1、Comparator.comparing和重写compare方法的使用(2个没有本质区别,都是排序)

2、collection后使用Collectors.groupingBy分组
var docSettlementCounts = docSettlements.stream().collect(Collectors.groupingBy(DocSettlementEntity::getProjectSettlementIdentifierNo, Collectors.counting()));
这里就会显示
{
projectSettlementIdentifierNo:数量}
边栏推荐
- [arXiv] notes on uploading papers for the first time
- Protocol buffers 的问题和滥用
- MySql的DDL和DML和DQL的基本语法
- SQLite数据库
- 阿里onedate分层思想
- [attack and defense world web] difficulty four-star 12 point advanced question: confusion1
- [isprint function determines whether characters can be output]
- 寻找消失的类名
- 二分函数细节
- Unity solves that animation is not available: the animationclip 'xxx' used by the animation component 'xxx' must be marked as legacy
猜你喜欢
随机推荐
欧氏聚类(API)及其单木分割
集群聊天服务器:网络模块ChatServer
The total ranking of blogs is 918
二分函数细节
PCL出错:error C2589“(“:“::“右边的非法标记)
CMake的学习
Sword finger offer Second Edition: string (simple)
H264 encoding parameters
手机测试相关基础知识
Bisection function details
MySql的DDL和DML和DQL的基本语法
集群聊天服务器:数据库表的设计
Problems and abuse of protocol buffers
Kuberntes云原生实战六 使用Rook搭建Ceph集群
Synchronized同步锁的基本原理
剑指 Offer II 115. 重建序列 : 拓扑排序构造题
软件体系结构期末复习六十题
存储结构和管理盘。有点像装win98要先分区格式化硬盘
Interval DP chain stone merging
Mysql database index









