public static void main(String[] args) { List<Integer> list = new ArrayList<>(); for(int i=0;i<100;i++){ list.add(i);} List<Integer> part1 = list.stream().limit(list.size()/2).collect(Collectors.toList()); List<Integer> part2 = list.stream().skip(list.size()/2).collect(Collectors.toList()); System.out.println("part1=="+part1); System.out.println("part2=="+part2); }
结果如图:
标签:分成,stream,一半,list,System,part1,part2,集合 From: https://www.cnblogs.com/wangweiip/p/16956038.html