How do I join two lists in Java?
来源:互联网 发布:基三捏脸数据 编辑:程序博客网 时间:2024/06/01 13:11
看到这个问题,你想到肯定是下面的这种方法:
List<String> newList = new ArrayList<String>();newList.addAll(listOne);newList.addAll(listTwo);
List<String> newList = new ArrayList<String>(listOne);newList.addAll(listTwo);在创建新列表的时候,将列表1传入新列表。
现在java8也出现了很久了呢?有没有java8的新特性可以利用的呢?有时候利用新特性,可以省略很多代码。
List<String> newList = Stream.concat(listOne.stream(), listTwo.stream()).collect(Collectors.toList());
1 0
- How do I join two lists in Java?
- How do I instantiate a Queue object in java?
- How do I compare strings in Java?(Stackoverflow)
- How do I debug JavaScript in Safari?
- How do I use Cygwin in Geophysics ?
- How do I install fonts in Fedora
- How do I write things in Swift?
- 1006. Join two lists
- How do I invite others to join Gmail?
- How Do I Compare Two Files and Show The Differences?
- 【Leetcode】Merge Two Sorted Lists in JAVA
- How do I get start in QA/Test
- How do I include one DTD (or fragment) in another?
- How do I set breakpoints in modal dialogs?
- How do I create delegates in Objective-C?
- How do I change the default runlevel in Feodra 15?
- How do I disable video thumbnails in Windows 7?
- How do I monitor HTTP communication in Eclipse?
- 【技术分享】Necurs僵尸网络它又回来了,威力强大可进行DDoS攻击
- caffe初探之-特征提取
- oracle使用手册
- Android Glide切换网络请求方式
- Linux常用命令的全称
- How do I join two lists in Java?
- ADB shell出现error:device offline提示
- Linux基础知识,新手必备
- Apache Solr入门教程(初学者之旅)
- java中形参String的可变参数的定义(String...)
- 线程间操作无效: 从不是创建控件“”的线程访问它
- HTTP请求的相关知识
- (转载)Git 的origin和master分析
- 前端学习