当前位置:网站首页>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)]
]
边栏推荐
- Uni app wechat applet one click login to obtain permission function
- How to add transactions in JDBC
- Anaconda installs the virtual environment to the specified path
- 一文读懂C语言中的结构体
- wireshark报文分析tcp,ftp
- [research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached
- 实例讲解将Graph Explorer搬上JupyterLab
- MySQL signale une erreur can 't create table' demo01. TB Étudiant '(errno: 150)
- 今日群里分享的面试题
- Anaconda安装虚拟环境到指定路径
猜你喜欢

Cookie和Session的相关概念

HLS4ML进入方法

EasyCVR通过国标GB28181协议接入设备,出现设备自动拉流是什么原因?

墨天轮沙龙 | 清华乔嘉林:Apache IoTDB,源于清华,建设开源生态之路

产品模块化设计的前世今生
![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled]

Process steps of vibrating wire acquisition module for measuring vibrating wire sensor

JS proxy

Why has instagram changed from a content sharing platform to a marketing tool? How do independent sellers use this tool?

SIP protocol of gb28181
随机推荐
[SQL optimization] the difference between with as and temporary tables
A brief understanding of white box encryption technology
【多线程】锁策略
2022/5/23-2022/5/30
Leetcode 1380 lucky numbers in matrix [array] the leetcode path of heroding
list大集合等比分割成多个小list集合
qobject_ Cast usage
Interview questions for audio and video positions in Dachang -- today's headline
Salesmartly has some tricks for Facebook chat!
Collect Tiktok video
703. The k-th element in the data flow
【let var const】
Anaconda安装虚拟环境到指定路径
Wireshark packet analysis TCP, FTP
再回顾集合容器
SIP protocol of gb28181
Define dichotomy lookup
2022/6/8-2022/6/12
How can a programmer grow rapidly
ModSim基本使用(Modbus模拟器)