当前位置:网站首页>获取两个集合相差数据
获取两个集合相差数据
2022-07-28 00:59:00 【ekkcole】
可以用来去除数据库和对比的集合不一致的数据
public class TestList {
public static void main(String[] args) {
// 浏览器
List<String> list = Arrays.asList( "2", "3", "4", "5");
// 数据库
List<String> list1 = Arrays.asList("1", "2", "4", "5", "7");
List<String> list2 =new ArrayList<>();
List<String> list3 =new ArrayList<>();
// list1中没有的
list2=list.stream().filter(e -> {
return !list1.contains(e);
}).collect(Collectors.toList());
// list中没有的
list3=list1.stream().filter(e -> {
return !list.contains(e);
}).collect(Collectors.toList());
System.out.println(list2);
System.out.println(list3);
}
}
边栏推荐
猜你喜欢

Codeforces Round #810 (Div. 2)A~C题解

学会这招再也不怕手误让代码崩掉

APP如何上架App Store?

Flume (5 demos easy to get started)

Synchronized details

软考 --- 数据库(2)关系模型

小程序毕设作品之微信校园维修报修小程序毕业设计成品(4)开题报告

Clear the cause of floating and six methods (solve the problem that floating affects the parent element and the global)

Starfish Os X MetaBell战略合作,元宇宙商业生态更进一步

Execute add migration migration and report build failed
随机推荐
Software testing interview question: why should we carry out testing in a team?
借助Elephant&nbsp;Swap打造的ePLATO,背后的高溢价解析
Skywalking distributed system application performance monitoring tool - medium
智能合约安全——selfdestruct攻击
CeresDAO:Ventures DAO的“新代言”
53: Chapter 5: develop admin management service: 6: develop [admin administrator exit login, interface]; (one point: when we want to modify a value with a certain coding method, the new value should b
Flex布局—固定定位+流式布局—主轴对齐—侧轴对齐—伸缩比
A lock faster than read-write lock. Don't get to know it quickly
Huawei app UI automation test post interview real questions, real interview experience.
In it, there is a million talent gap, and the salary rises, but it is not capped
Principle and implementation of cross entropy
Cloud native enthusiast weekly: the evolution of Prometheus architecture
云原生爱好者周刊:Prometheus 架构演进之路
Four common post data submission methods
软件测试面试题:请详细介绍一下各种测试类型的含义?
样本不均衡-入门0
Sample imbalance - entry 0
WMS you don't know
软件测试面试题:常见的 POST 提交数据方式
Flex布局学习完成PC端