当前位置: 首页 > 编程笔记 >

JAVA8 List> list中再装一个list转成一个list操作

罗心思
2023-03-14
本文向大家介绍JAVA8 List > list中再装一个list转成一个list操作,包括了JAVA8 List > list中再装一个list转成一个list操作的使用技巧和注意事项,需要的朋友参考一下

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

  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操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持小牛知识库。

 类似资料:
  • 本文向大家介绍Python中将两个或多个list合成一个list的方法小结,包括了Python中将两个或多个list合成一个list的方法小结的使用技巧和注意事项,需要的朋友参考一下 python中,list这种数据结构很常用到,如果两个或者多个list结构相同,内容类型相同,我们通常会将两个或者多个list合并成一个,这样我们再循环遍历的时候就可以一次性处理掉了。所以如何将两个或者多个list合

  • 本文向大家介绍java实现把一个List集合拆分成多个的操作,包括了java实现把一个List集合拆分成多个的操作的使用技巧和注意事项,需要的朋友参考一下 有些时候我们需要对一批数据进行分批处理, 使用subList方法可以实现对List集合进行固定长度的分割. 输出结果: 补充知识:java将大集合按照固定长度拆分为小集合 我们在使用java中的集合(Collection、List、Set等)的

  • Rotate List 描述 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->nullptr and k = 2, return 4->5->1->2->3->nullptr. 分析 先遍历一遍,得出链表长度len,注

  • Reorder List 描述 Given a singly linked list $$L: L0 \rightarrow L_1 \rightarrow \cdots \rightarrow L{n-1} \rightarrow Ln$$, reorder it to: $$L_0 \rightarrow L_n \rightarrow L_1 \rightarrow L{n-1} \righ

  • Partition List 描述 Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the n