当前位置 : 主页 > 编程语言 > java >

JAVA8 List<List<Integer>> list中再

来源:互联网 收集:自由互联 发布时间:2021-04-10
我就废话不多说了,大家还是直接看代码吧~ ListInteger collect = IntStream.range(1, 10).boxed().collect(Collectors.toList()); ListInteger collect1 = IntStream.range(10, 20).boxed().collect(Collectors.toList()); ListListInteg

我就废话不多说了,大家还是直接看代码吧~

  List<Integer> collect = IntStream.range(1, 10).boxed().collect(Collectors.toList());
  List<Integer> collect1 = IntStream.range(10, 20).boxed().collect(Collectors.toList());

  List<List<Integer>> lists = new ArrayList<>();
  lists.add(collect);
  lists.add(collect1);
  ArrayList<Integer> collect2 = lists.stream().collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll);
  System.out.println(collect2);

补充知识:java 8 转复杂的list对象转为单一的list

我就废话不多说了,大家还是直接看代码吧~

journal.snList= Arrays.asList(pvData.t97).stream().sorted(Comparator.comparing(T97FgLog::getF97Sn))

.map(T97FgLog::getF97Sn).collect(Collectors.toList());

关键是要用map来返回其中一个属性.

以上这篇JAVA8 List> list中再装一个list转成一个list操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

网友评论