当前位置:网站首页>list大集合等比分割成多个小list集合
list大集合等比分割成多个小list集合
2022-07-01 18:47:00 【码农巅峰】
一:实体对象准备
package cn.nhdc.cloud.common.annotation;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class Order {
/**
* 订单id
*/
private String orderId;
/**
* 订单名称
*/
private String orderName;
}
二:测试案例
package cn.nhdc.cloud.common.annotation;
import cn.hutool.core.collection.ListUtil;
import java.util.ArrayList;
import java.util.List;
public class Test11 {
public static void main(String[] args) {
List<Order> orders = new ArrayList<Order>() {
{
add(Order.builder().orderId("1").orderName("订单1").build());
add(Order.builder().orderId("2").orderName("订单2").build());
add(Order.builder().orderId("3").orderName("订单3").build());
add(Order.builder().orderId("4").orderName("订单4").build());
add(Order.builder().orderId("5").orderName("订单5").build());
add(Order.builder().orderId("6").orderName("订单6").build());
add(Order.builder().orderId("7").orderName("订单7").build());
}};
List<List<Order>> partition = ListUtil.partition(orders, 2);
System.err.println(partition);
List<List<Order>> split = ListUtil.split(orders, 3);
System.err.println(split);
}
}
三:运行结果
[
[Order(orderId=1, orderName=订单1), Order(orderId=2, orderName=订单2)],
[Order(orderId=3, orderName=订单3), Order(orderId=4, orderName=订单4)],
[Order(orderId=5, orderName=订单5), Order(orderId=6, orderName=订单6)],
[Order(orderId=7, orderName=订单7)]
]
[
[Order(orderId=1, orderName=订单1), Order(orderId=2, orderName=订单2), Order(orderId=3, orderName=订单3)],
[Order(orderId=4, orderName=订单4), Order(orderId=5, orderName=订单5), Order(orderId=6, orderName=订单6)],
[Order(orderId=7, orderName=订单7)]
]
边栏推荐
- [Mori city] random talk on GIS data (I)
- Bao, what if the O & M 100+ server is a headache? Use Xingyun housekeeper!
- Wireshark packet analysis TCP, FTP
- 音频编解码基础知识
- tensorflow报错Could not load dynamic library ‘libcudnn.so.8
- Optimization of video streaming with repeated requests in the case of unstable easygbs network
- P2433 [deep foundation 1-2] primary school mathematics n in one
- wireshark报文分析tcp,ftp
- Technology T3 domestic platform! Successfully equipped with "Yihui domestic real-time system sylixos"
- 直播HLS协议
猜你喜欢
Wireshark packet analysis TCP, FTP
uni-app微信小程序一键登录获取权限功能
pickle. Load error [attributeerror: can't get attribute 'volatile' on < module '\u main']
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached
Thesis reading [distinctive late semantic graph for video capturing]
科技T3国产平台!成功搭载“翼辉国产实时系统SylixOS”
ddr4测试-2
How to correctly use vertx to operate redis (3.9.4 with source code analysis)
Actual combat of flutter - fast implementation of audio and video call application
118. 杨辉三角
随机推荐
Cookie和Session的相关概念
After studying 11 kinds of real-time chat software, I found that they all have these functions
面试题 16.16. 部分排序-双指针法
MySQL reports an error can't create table 'demo01 tb_ Student‘ (errno: 150)*
如何正确使用Vertx操作Redis(3.9.4带源码分析)
Crunch简介、安装,使用Crunch制作密码字典
GC垃圾回收
js三元表达式复杂条件判断
事务隔离级别 gap锁 死锁
GC garbage collection
Actual combat of flutter - fast implementation of audio and video call application
Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
Analysis of GetMessage underlying mechanism
【AI服务器搭建】CUDA环境
Redo和Undo的区别
Interview questions for audio and video positions in Dachang -- today's headline
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
【sql优化】with as 和 临时表的区别
H264编码profile & level控制
类加载机制