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
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容