java 分批同时处理_java中List集合分批处理

在项目中存在list集合数据量过大,需要对这个list集合进行分批处理,自己写了一个list分批处理的一个算法:

package com.lv.huizhong.demo;

import java.util.ArrayList;

import java.util.List;

public class ListSplit {

public static void main(String[] args) {

List list = new ArrayList();

for (int i = 0; i < 520; i++) {

list.add(i);

}

ListSplit.test1(list);

}

public static void test1(List dataList){

int pointsDataLimit = 50;

List newList = new ArrayList();

for(int i=0;i

newList.add(dataList.get(i));

if(pointsDataLimit == newList.size()||i == dataList.size()-1){

printList(newList);

newList.clear();

System.out.println("");

System.out.println("=====");

}

}

}

public static void printList(List dataList){

for(Object str : dataList){

System.out.print(str + " -- ");

}

}

}

85a07d51d45b7ab5ad6b1aef46471b92.png

这样list分批就写好了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/417306.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ie当前正在禁用加载项的状态下运行,要管理或删除加载项

右击快捷方式——属性 目标栏中删除后面的 “-xxx”参数

java work stealing_Java线程池之WorkStealingPool,任务窃取算法

1 import java.io.IOException;2 import java.util.concurrent.ExecutorService;3 import java.util.concurrent.Executors;4 import java.util.concurrent.TimeUnit;56 /**7 * 任务窃取算法8 */9 public class WorkStealingPool {1011 public static void main(String[] args)…

基于keepalived 实现VIP转移,lvs,nginx的高可用

一、Keepalived 高可用集群的解决方案 二、VRRP的有限状态机 三、利用keepalived 实现主从VIP的切换 四、 实现在状态转变的时候自定义进行通知&#xff0c; 五、 实现负载均衡 六&#xff1a;实现nginx的高可用 一、Keepalived 高可用集群的解决方案 最初的诞生是为ipvs提供高…

php进程状态进度,PHP监控进程状态,完成掉线自动重启

1. 利用Shell脚本实现#!/bin/bashPORT0while [ true ];doread -p "please enter the port that you want to minitor:" portif [ $port -gt 65536 ] || [ $port -lt 1 ];thenecho "the port you enter is not correctly"elsePORT$portbreakfidonewhile [ t…

Win8 Consumer Preview 8250 + VS11 体验

开始界面 桌面&#xff0c;背景换成金鱼了&#xff0c;安装的第一步也是这条鱼……VS11的安装界面&#xff0c;变化好大 IIS8IE10

caffe源码阅读(1)_整体框架和简介(摘录)

原文链接&#xff1a;https://www.zhihu.com/question/27982282 1.Caffe代码层次。回答里面有人说熟悉Blob&#xff0c;Layer&#xff0c;Net&#xff0c;Solver这样的几大类&#xff0c;我比较赞同。我基本是从这个顺序开始学习的&#xff0c;这四个类复杂性从低到高&#xff…

JavaMail--发送html邮件

//发邮件用到的两个包"org.springframework:spring-context-support:$springVersion","javax.mail:mail:1.4.7" web.xml <?xml version"1.0" encoding"UTF-8"?> <web-app xmlns"http://xmlns.jcp.org/xml/ns/javaee&q…

阿里云CentOS服务器挂载数据盘

本次使用的是centOS6.7 64位系统 第一步&#xff1a;处理阿里云磁盘挂载问题 查看磁盘情况&#xff0c;本次机器系统盘为阿里云赠送的20G&#xff0c;数据盘为100G 其中/dev/xvda为系统盘&#xff0c;/dev/xvdb为数据盘&#xff0c;数据盘暂未做任何操作&#xff0c;要使用的话…

php ci post 请求,CI框架中判断post,ajax,get请求的方法

这篇文章主要介绍了关于CI框架中判断post,ajax,get请求的方法 &#xff0c;有着一定的参考价值&#xff0c;现在分享给大家&#xff0c;有需要的朋友可以参考一下CI框架当中并没有提供&#xff0c;类似tp框架中IS_POST,IS_AJAX,IS_GET的方法。所有就得我们自己造轮子了。下面就…

[position]返回顶部

position:fixed;实现 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>返回顶部</title> </head> <body style"margin: 0"> <div style"width: 50px;height: 50px…

php 自定义行间距,phpstorm 常见设置

0.转载于 http://www.cnblogs.com/dc10101/archive/2013/01/03/2842590.html1.关于字体颜色 亮度 调整内容如下&#xff1a;ctrlalts打开Settings界面&#xff0c;Editor > Colors&Fonts > Font。Default scheme是亮色调&#xff0c;但我想定制一套暗背景的环境&…

POJ1430 Binary Stirling Numbers

(POJ)[Stirling數, 排列組合, 數形結合] Description The Stirling number of the second kind S(n, m) stands for the number of ways to partition a set of n things into m nonempty subsets. For example, there are seven ways to split a four-element set into two pa…

php 页面加载进度条,HTML5/CSS3 网页加载进度条的实现,下载进度条等经典案例

今天给大家带来一个比较炫的进度条&#xff0c;进度条在一耗时操作上给用户一个比较好的体验&#xff0c;不会让用户觉得在盲目等待&#xff0c;对于没有进度条的长时间等待&#xff0c;用户会任务死机了&#xff0c;毫不犹豫的关掉应用&#xff1b;一般用于下载任务&#xff0…

java web项目中连接mysql数据库,javaweb之eclipse工程连接mysql数据库

javaweb之eclipse工程连接mysql数据库准备工作&#xff1a;1.在mysql官网下载mysqlconnection的jar包输入网址&#xff1a;mysql.com—点击DOWNLOADS——下拉选择MySQL Community (GPL) Downloads ——选择Connector/J——下载后解压——找到mysql-connector-java-8.0.22.jar2.…

Win7的市场份额终于超过XP了,以后可以逐渐考虑放弃ie6/7了!

Win7的市场份额终于超过XP了&#xff0c;以后可以逐渐考虑放弃ie6/7了&#xff01; 开心啊&#xff0c;诸位web开发们…… 图片来源&#xff1a;http://thenextweb.com/microsoft/2012/09/01/windows-7-finally-overtakes-windows-xp-mac-os-x-overtakes-windows-vista/

SWIFT推送之本地推送(UILocalNotification)之二带按钮的消息

上一篇讲到的本地推送是普通的消息推送&#xff0c;本篇要讲一下带按钮动作的推送消息&#xff0c;先上个图瞅瞅&#xff1a; 继上一篇的内容进行小小的改动&#xff1a; 在didFinishLaunchingWithOptions方法内进行以下修改 123456789101112131415161718192021222324252627282…

树状数组基础

关于树状数组的讲解推荐《算法竞赛入门经典训练指南》 一维版本&#xff1a; 洛谷3374 分析&#xff1a;树状数组裸的模板题 1 #include<iostream>2 #include<cstdio>3 #include<cstring>4 using namespace std;5 const int maxn50000010;6 int c[maxn];7 in…

vue1升级到vue2的问题

router 不能用map方法了&#xff0c;需要改router的结构改为routers [ { // 当没有匹配路由时默认返回的首页 path:/index, component: index, authenticate:true }, { // 当没有匹配路由时默认返回的首页 path: /spa/, component: i…