时间:2021-08-28 09:28:05 | 栏目:JAVA代码 | 点击:次
我就废话不多说了,大家还是直接看代码吧~
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来返回其中一个属性.