当前位置:网站首页>The large list set is divided into multiple small list sets in equal proportion
The large list set is divided into multiple small list sets in equal proportion
2022-07-01 19:50:00 【Manong peak】
One : Entity object preparation
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 {
/**
* Order id
*/
private String orderId;
/**
* Name of the order
*/
private String orderName;
}
Two : Test cases
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(" Order 1").build());
add(Order.builder().orderId("2").orderName(" Order 2").build());
add(Order.builder().orderId("3").orderName(" Order 3").build());
add(Order.builder().orderId("4").orderName(" Order 4").build());
add(Order.builder().orderId("5").orderName(" Order 5").build());
add(Order.builder().orderId("6").orderName(" Order 6").build());
add(Order.builder().orderId("7").orderName(" Order 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);
}
}
3、 ... and : Running results
[
[Order(orderId=1, orderName= Order 1), Order(orderId=2, orderName= Order 2)],
[Order(orderId=3, orderName= Order 3), Order(orderId=4, orderName= Order 4)],
[Order(orderId=5, orderName= Order 5), Order(orderId=6, orderName= Order 6)],
[Order(orderId=7, orderName= Order 7)]
]
[
[Order(orderId=1, orderName= Order 1), Order(orderId=2, orderName= Order 2), Order(orderId=3, orderName= Order 3)],
[Order(orderId=4, orderName= Order 4), Order(orderId=5, orderName= Order 5), Order(orderId=6, orderName= Order 6)],
[Order(orderId=7, orderName= Order 7)]
]
边栏推荐
- 事务隔离级别 gap锁 死锁
- Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, builds an open source ecological road
- Use the uni app demo provided by Huanxin to quickly realize one-on-one chat
- Opencv video quality detection -- sharpness detection
- Procédure de mesure du capteur d'accord vibrant par le module d'acquisition d'accord vibrant
- How to add transactions in JDBC
- P2433 【深基1-2】小学数学 N 合一
- servlet知识点
- 振弦采集模塊測量振弦傳感器的流程步驟
- 墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
猜你喜欢
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Modsim basic use (Modbus simulator)
有意思了!数据库也搞Serverless!
墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路
Cookie和Session的相关概念
windows环境 redis安装和启动(后台启动)
Interview questions for audio and video positions in Dachang -- today's headline
全国职业院校技能大赛网络安全“splunk“详细配置
Basic use of MySQL
Optimization of video streaming with repeated requests in the case of unstable easygbs network
随机推荐
一文读懂C语言中的结构体
JS 之 常用内置类的使用
Transaction isolation level gap lock deadlock
After studying 11 kinds of real-time chat software, I found that they all have these functions
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
tensorflow报错Could not load dynamic library ‘libcudnn.so.8
Source code series of authentic children -inheritablethreadlocal (line by line source code takes you to analyze the author's ideas)
SQL 入门计划-1-选择
振弦采集模塊測量振弦傳感器的流程步驟
qobject_ Cast usage
Anaconda installs the virtual environment to the specified path
音视频、编解码相关电子书、小工具,打包奉送!
Ffmpeg common commands (2)
The key to the success of digital transformation enterprises is to create value with data
JVM memory model
Unreal Engine packaging project
DTD modeling
【多线程】锁策略
博途V16 获取系统时间转换成字符串
PowerDesigner设计Name和Comment 替换