addAll  添加另一集合里面的元素

add 添加整个集合包括 []

Stream 操作 合并两个lis  出自http://www.it1352.com/963663.html

 public class Test {
public static void main(String[] args) { List<String> destList = Collections.synchronizedList(new ArrayList<>(Arrays.asList("foo"))); List<String> newList = Arrays.asList("0", "1", "2", "3", "4", "5"); newList.stream().sequential().collect(Collectors.toCollection(() -> destList)); //newList + destList 的内容
//结果 [foo, 0, 1, 2, 3, 4, 5]
System.out.println(destList); System.out.println("=========================================="); List<String> listOne = new ArrayList<String>();
listOne.add("333");
listOne.add("666");
listOne.add("999"); List<String> listTwo = new ArrayList<String>();
listTwo.add("A");
listTwo.add("B");
listTwo.add("C"); //addAll 添加另一集合里面的元素
//结果[333, 666, 999, A, B, C]
listOne.addAll(listTwo);
System.out.println(listOne); //add 添加整个集合包括 []
//结果 [A, B, C, [333, 666, 999, A, B, C]]
listTwo.add(listOne.toString());
System.out.println(listTwo); } }

两个list合并成一个list的操作的更多相关文章

  1. Clojure:将两个list合并成一个map

    假设我们有两个list,分别是: (def a [“one” “two” “three”]) (def b [1 2 3]) 我们要把它们合为一个键值对应的map,做法很简单: 1. 先将a和b合为一 ...

  2. 将两个DataTable合并成一个DataTable

    转载自 http://blog.csdn.net/wangxiaojia42121/article/details/53330464 谢谢 //两个结构一样的DT合并DataTable DataTab ...

  3. python基础===两个list合并成一个dict的方法

    def Run(): list2 = [, , , , ]; list3 = ["a", "b", "c", "d",& ...

  4. 如何将两个json合并成一个

    //调用方法: var targetObject = [{name:"11",age:11}]; var sourceObject = [{name:"22", ...

  5. python中如何将两个list合并成一个list,不用for语句

    1, add 2, 用list的extend方法,L1.extend(L2),该方法将参数L2的全部元素添加到L1的尾部,例如: 3, 用切片(slice)操作,L1[len(L1):len(L1)] ...

  6. 两个NSMutableDictionary合并成一个NSMutableDictionary

    解决方案: NSMutableDictionary *targetMutableDictionary = [mutableDictionary1 copy]; [targetMutableDictio ...

  7. 多个UIImage合并成一个UIImage

    多个UIImage合并成一个UIImage 创建两个UIImage UIImage *image1 = [UIImage imageNamed:@"iOSDevTip"]; UII ...

  8. Java中如何把两个数组合并为一个

    在Java中,如何把两个String[]合并为一个? 看起来是一个很简单的问题.但是如何才能把代码写得高效简洁,却还是值得思考的.这里介绍四种方法,请参考选用. 一.apache-commons 这是 ...

  9. C#程序(含多个Dll)合并成一个Exe

    把C#程序(含多个Dll)合并成一个Exe的超简单方法   开发程序的时候经常会引用一些第三方的DLL,然后编译生成的exe文件就不能脱离这些DLL独立运行了. 但是,很多时候我们本想开发一款只需要一 ...

随机推荐

  1. elasticSearch的部署和使用

    部署服务 docker run启动elastic服务 docker pull elasticsearch:6.7.2 docker run -d -p 9200:9200 -p 9300:9300 - ...

  2. 基于SpringBoot前后端分离的点餐系统

    基于SpringBoot前后端分离的点餐系统 开发环境:主要采用Spring boot框架和小程序开发 项目简介:点餐系统,分成卖家端和买家端.买家端使用微信小程序开发,实现扫码点餐.浏览菜单.下单. ...

  3. Pluralsight 科技公司公布自己的avaScript 成为最受欢迎的开发技术

    根据 SDTimes 报道,Pluralsight 科技公司公布自己的 Technology Index,JavaScript 位居榜首. Pluralsight,是美国的一家面向软件开发者的在线教育 ...

  4. 文本切换器(TextSwitcher)的功能与用法

    TextSwitcher继承了ViewSwitcher,因此它具有与ViewSwitcher相同的特征:可以在切换View组件时使用动画效果.与ImageSwitcher相似的是,使用TextSwit ...

  5. AVAssetDownloadURLSession

    NSURLSession 的子类,用于支持创建和执行资产下载任务的URL会话,主要是用来下载HLS资源内容的 AVAssetDownloadURLSession reference https://d ...

  6. Netfilter,获取http明文用户名和密码

    目录 Netfilter简介 实验-target端 内核模块的操作 初始化netfilter 解析http包,获取用户名和密码 实验-hack端 遇到的问题 @ Netfilter简介 Netfilt ...

  7. 18c & 19c Physical Standby Switchover Best Practices using SQL*Plus (Doc ID 2485237.1)

    18c & 19c Physical Standby Switchover Best Practices using SQL*Plus (Doc ID 2485237.1) APPLIES T ...

  8. CentOS自动化安装LAMP脚本

    #!/bin/bash #-- #blog:lizhenliang.blog.51cto.com ########## function ########## depend_pkg () { yum ...

  9. ccf-csp201809题解

    目录 ccf-csp201809题解 1. 201809-1 卖菜 题目描述 解析 通过代码 2. 201809-2 买菜 题目描述 解析 通过代码 3.201809-3 元素选择器 题目描述 解析 ...

  10. [译]Vulkan教程(16)图形管道基础之总结

    [译]Vulkan教程(16)图形管道基础之总结 Conclusion 总结 We can now combine all of the structures and objects from the ...