当前位置:网站首页>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)]
]
边栏推荐
- 再回顾集合容器
- Proxy in ES6
- Time series analysis using kibana timelion
- DTD modeling
- 今日群里分享的面试题
- [research materials] Huawei Technology ICT 2021: at the beginning of the "Yuan" year, the industry is "new" -- download attached
- 【无标题】
- February 15, 2022: sweeping robot. There is a floor sweeping robot in the room (represented by a grid). Each grid in the grid has two possibilities: empty and obstacles. The sweeping robot provides fo
- Wechat applet realizes keyword highlighting
- Redo和Undo的区别
猜你喜欢

【多线程】锁策略

Crunch简介、安装,使用Crunch制作密码字典

类加载机制

Interview questions for audio and video positions in Dachang -- today's headline

一个悄然崛起的国产软件,低调又强大!

GC垃圾回收

振弦采集模块测量振弦传感器的流程步骤

Interview question 1
![[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached](/img/50/926cc5bce83f8b195b3e2072b656bf.jpg)
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached

HLS4ML进入方法
随机推荐
servlet知识点
Battery simulation of gazebo robot
Wechat applet realizes keyword highlighting
Image acquisition and playback of coaxpress high speed camera based on pxie interface
optaplanner学习笔记(一)案例Cloud balance
JS ternary expression complex condition judgment
DS transunet: Dual Swing transformer u-net for medical image segmentation
H264 encoding profile & level control
Compile ffmpeg source code with msys+vs2019 under win10
新增订单如何防止重复提交
SQL 入门计划-1-选择
Collect Tiktok video
How to use console Log print text?
2022/5/23-2022/5/30
JS 之 常用内置类的使用
对象的创建
EasyCVR集群视频广场页面切换时,请求流未能终止的问题优化
qobject_cast用法
新窗口打开页面-window.open
How can a programmer grow rapidly