作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有两个不同的列表字符串,
List<String> A= [1,2,3,4];
List<String> B= [1,2,5,6];
我想合并两个列表,在新的列表字符串中 List C = new Arraylist();
如何合并两个列表字符串,如示例:
C = [1,2,3,4,5,6];
最佳答案
使用Collection.addAll() , 和一个 TreeSet , 以删除重复项并保持结果排序。
Set<String> c = new TreeSet<String>(a); //create a Set with all the elements in a
c.addAll(b); //add all the elements in b
关于java - 如何将两个列表字符串组合成一个列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14019751/
我是一名优秀的程序员,十分优秀!