搭建论坛网站使用的系统,钓鱼网站链接,重庆微信网站开发公司,学ui的网站在开发过程中可能会遇到需要处理的List数据量过大#xff0c;可以选择分批处理的方式对大量数据进行处理。
1、使用 apache 的工具包
dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-collections4/artifactIdv…在开发过程中可能会遇到需要处理的List数据量过大可以选择分批处理的方式对大量数据进行处理。
1、使用 apache 的工具包
dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-collections4/artifactIdversion4.4/version
/dependency代码示例Lists.partition() ListInteger listnew ArrayList();for (int i0;i500;i){list.add(i);}ListListInteger newList Lists.partition(list, 150);for (ListInteger subset:newList){System.out.println(subset.size());}2、使用 guava 的工具包
dependencygroupIdcom.google.guava/groupIdartifactIdguava/artifactIdversion31.0.1-jre/version
/dependency代码示例Lists.partition() ListInteger listnew ArrayList();for (int i0;i500;i){list.add(i);}ListListInteger newList Lists.partition(list, 150);for (ListInteger subset:newList){System.out.println(subset.size());}当然还有其他工具包也封装了List分批处理的函数。 参考链接 https://blog.csdn.net/qq_35387940/article/details/121612391