我就废话不多说了,大家还是直接看代码吧~
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操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持自学编程网。
- 本文固定链接: https://zxbcw.cn/post/194185/
- 转载请注明:必须在正文中标注并保留原文链接
- QQ群: PHP高手阵营官方总群(344148542)
- QQ群: Yii2.0开发(304864863)