public static void main(String[] args) {
String[] arrayA = new String[] { "a", "b", "c", "d", "e", "d" };
String[] arrayB = new String[] { "d", "c", "2", "d", "e", "b" };
List a = Arrays.asList( arrayA );
List b = Arrays.asList( arrayB );
Collection union = CollectionUtils.union( a, b );
Collection intersection = CollectionUtils.intersection( a, b );
Collection disjunction = CollectionUtils.disjunction( a, b );
Collection subtract = CollectionUtils.subtract( a, b );
Collections.sort((List) union );
Collections.sort((List) intersection );
Collections.sort((List) disjunction );
Collections.sort((List)subtract );
System.out.println( "A: " + ArrayUtils.toString( a.toArray( ) ) );
System.out.println( "B: " + ArrayUtils.toString( b.toArray( ) ) );
System.out.println( "Union: " + ArrayUtils.toString( union.toArray( ) ) );
System.out.println( "Intersection: " +
ArrayUtils.toString( intersection.toArray( ) ) );
System.out.println( "Disjunction: " +
ArrayUtils.toString( disjunction.toArray( ) ) );
System.out.println( "Subtract: " + ArrayUtils.toString( subtract.toArray( ) ) );
}
分享到:
相关推荐
集合实用程序 CollectionUtils 类
主要为大家详细介绍了java拓展集合工具类CollectionUtils,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
Java_Collections CollectionUtils 类具有以下静态方法: List<E> map(List, ListMapper),List<E> filter(List, ListFilter );
Java开发中中经常使用的Java工具类分享,工作中用得上,直接拿来使用,不用重复造轮子。
Apache Commons Collections,commons-collections-3.2.1和commons-collections4-4.0,含jar包及源码和api文档。
struts2常用的一些jar包.rar
集合实用程序 不同的收藏
是一个集合组件,扩展了Java标准Collections API,对常用的集合操作进行了很好的封装、抽象和补充,在保证性能的同时大大简化代码。
集合实用程序 用java编写库函数
SQL中CONVERT转化函数的用法
Commons-Collections seek to build upon the JDK classes by providing new interfaces, implementations and utilities. There are many features, including: Bag interface for collections that have a number...
org.apache.commons 的经典jar 包 commons-beanutils-1.8.0-bin、 commons-betwixt-0.8、 commons-cli-1.1、 commons-codec-1.3、 commons-collections-3.2.1-bin、 commons-digester-1.8、 ...
if (CollectionUtils.isEmpty(fileDTOs)) { continue; }
commons-collections4-4.1.jar
简介这是学习JAVA的练习代码, 主要提供工具函数使用/*[ {id: 1, name: "name1", gender: 1}, {id: 2, name: "name2", gender: 1}, {id: 3, name: "name1", gender: 2},]*//*[1, 2, 3]*/CollectionUtils.pluck...
CollectionUtils.isEmpty(nodes)) { nodes.forEach(dataSourceBean -> { // 创建Redis分片 JedisShardInfo shardInfo = new JedisShardInfo(dataSourceBean.getHost(), dataSourceBean.getPort(), dataSource...
Azylee.Core 模块: 包含常用的工具方法 无其他第三方引用 ... ┣ CollectionUtils:集合处理 ┣ ArrayTool.cs // 数组格式化 ┣ ListTool.cs // 列表内容判断 ┗ Ls.cs // 列表内容判断(ListTool)
appkernel-commons 一组有用的 Android 助手类快速概述: com.appkernel.io Cache - Cache抽象单线程同步和异步实现FileCache - Cache文件支持实现IOUtils - 使用 IO 通道和所有类型类的无异常close()方法的简单工作...
apache工具类,StringUtil和CollectionUtils,,以及其他的Util,apache工具类,StringUtil,,以及其他的Util,
1.2,收藏CollectionUtils从一个列表中查找符合一定条件的对象。 2,太阳 2.1,发送邮件javax.mail完成邮件的发送和接收。 3,MyBatis 3.1,基本使用数据库基本操作。 4,开放交响曲 4.1,石英石英定时器及管理...