Welcome to my website, have a nice day!
Dream it, Do it, Make it!

Java按指定大小将List拆分为多个List

如何将一个List按照指定大小,均分(最后一个可能个数不一样)为多个List呢?有两种方式实现:

1.Google Guava

com.google.common.collect.Lists.partition(List<T> list,
                                          int size)

2.Apache Common

org.apache.commons.collections4.ListUtils.partition(List<T> list,
                                          int size)

参考:

  1. com.google.common.collect.Lists
  2. org.apache.commons.collections4.ListUtils
赞(0)
未经允许禁止转载:Ddmit » Java按指定大小将List拆分为多个List

评论 抢沙发

登录

找回密码

注册