当前位置: 首页 > news >正文

list交并补差集合

list交并补差集合

工具类依赖

<dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.8.1</version>
</dependency><dependency><groupId>commons-collections</groupId><artifactId>commons-collections</artifactId><version>3.2</version>
</dependency>

参考代码

		// 交并补差List<Integer> list1 = Lists.newArrayList(1,2,3);List<Integer> list2 = Lists.newArrayList(3,4,5);List<Integer> intersection = (List<Integer>) CollectionUtils.intersection(list1, list2);log.info("list1与list2交集:[{}]",intersection);List<Integer> unionResult = (List<Integer>) CollectionUtils.union(list1, list2);log.info("list1与list2并集:[{}]",unionResult);List<Integer> subtractList = (List<Integer>) CollectionUtils.subtract(list1, list2);log.info("list1与list2差集:[{}]",subtractList);List<Integer> subtractListSecond = (List<Integer>) CollectionUtils.subtract(list2, list1);log.info("list2与list1差集:[{}]",subtractListSecond);List<Integer> disjunctionList = (List<Integer>) CollectionUtils.disjunction(list1, list2);log.info("list1与list2补集:[{}]",disjunctionList);

00:05:52.126 [main] INFO com.geekmice.sbeasypoi.service.impl.ds - list1与list2交集:[[3]]
00:05:52.136 [main] INFO com.geekmice.sbeasypoi.service.impl.ds - list1与list2并集:[[1, 2, 3, 4, 5]]
00:05:52.147 [main] INFO com.geekmice.sbeasypoi.service.impl.ds - list1与list2差集:[[1, 2]]
00:05:52.147 [main] INFO com.geekmice.sbeasypoi.service.impl.ds - list2与list1差集:[[4, 5]]
00:05:52.149 [main] INFO com.geekmice.sbeasypoi.service.impl.ds - list1与list2补集:[[1, 2, 4, 5]]

在这里插入图片描述

http://www.lryc.cn/news/108198.html

相关文章:

  • 【微信小程序】父组件修改子组件数据或调用子组件方法
  • frp通过nginx映射multipart/x-mixed-replace; boundary=frame流媒体出外网访问
  • Kubernetes概述
  • Jmeter教程
  • 用Rust实现23种设计模式之建造者模式
  • 聚观早报 | 腾讯字节等企业驰援防汛救灾;新能源车7月销量单出炉
  • Crack:CAD Exchanger SDK 3.20 Web Toolkit 应用
  • 改造 ChatGPT-Next-Web 项目重新生成 Docker 镜像
  • git修改commit日志
  • Qt之qml和widget混合编程调用
  • 深度学习torch基础知识
  • 【JAVA】正则表达式是啥?
  • 网络安全之原型链污染
  • 【腾讯云Cloud Studio实战训练营】使用Cloud Studio迅捷开发一个3D家具个性化定制应用
  • 【计算机网络】第四章 网络层(一)
  • Elasticsearch删除文档
  • MySQL数据库如何实现AX规范
  • mac安装nvm
  • 使用 ckeditor gem
  • Windows环境下Node.js二进制版安装教程
  • Spring中的注解装配
  • 深度优先搜索|130, 200
  • go-resty
  • 香港服务器速度不稳定的原因有哪些
  • 企业架构NOSQL数据库之MongoDB
  • 鸟哥马哥共叙Linux发展
  • OpenCV中常用算子
  • Android 11.0 系统限制上网系列之iptables用IOemNetd实现app某个时间段禁止上网的功能实现
  • 【JavaSE】面向对象编程思想之继承
  • Golang make和new的区别