apache commons-collections.jar集合工具类
来源:互联网 发布:单片机连接共阴数码管 编辑:程序博客网 时间:2024/05/17 08:11
apache commons-collections.jar java 集合 交集 并集等
import java.util.Arrays;import java.util.Collection;import java.util.Collections;import java.util.List;import org.apache.commons.collections.CollectionUtils;import org.apache.commons.lang.ArrayUtils;public class CollectionUtilsIntro { @SuppressWarnings("unchecked") public static void main(String[] args) { String[] arrayA = new String[] { "1", "2", "3", "3", "4", "5" }; String[] arrayB = new String[] { "3", "4", "4", "5", "6", "7" }; List<String> a = Arrays.asList(arrayA); List<String> b = Arrays.asList(arrayB); //并集 Collection<String> union = CollectionUtils.union(a, b); //交集 Collection<String> intersection = CollectionUtils.intersection(a, b); //交集的补集 Collection<String> disjunction = CollectionUtils.disjunction(a, b); //集合相减 Collection<String> subtract = CollectionUtils.subtract(a, b); Collections.sort((List<String>) union); Collections.sort((List<String>) intersection); Collections.sort((List<String>) disjunction); Collections.sort((List<String>) subtract); System.out.println("A: " + ArrayUtils.toString(a.toArray())); System.out.println("B: " + ArrayUtils.toString(b.toArray())); System.out.println("--------------------------------------------"); System.out.println("Union(A, B): " + ArrayUtils.toString(union.toArray())); System.out.println("Intersection(A, B): " + ArrayUtils.toString(intersection.toArray())); System.out.println("Disjunction(A, B): " + ArrayUtils.toString(disjunction.toArray())); System.out.println("Subtract(A, B): " + ArrayUtils.toString(subtract.toArray())); }}
- apache commons-collections.jar集合工具类
- 集合工具类 org.apache.commons.collections.CollectionUtils
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- apache commons collections CollectionUtils工具类简单使用
- 集合工具类Collections
- 集合工具类Collections
- Collections集合工具类
- 集合工具类 Collections
- Commons-Collections.jar
- Commons-Collections.jar
- apache commons collections
- apache commons collections
- Apache Commons Collections
- Apache Commons Collections
- vim随笔提示
- HDU 3667 Transportation 费用流(拆边)
- POJ 1011
- GetWindowRect
- web开发下的各种下载方法
- apache commons-collections.jar集合工具类
- mini2440 Uboot错误解决
- C#操作数据库
- Android_Build类获取手机硬件信息
- 修改电脑的localhost为自己的姓名
- Strange Dialog
- 解决异常“android.view.InflateException: Binary XML file line # : Error inflating class”
- 两程序员不同境遇:少抱怨 多解决问题
- C++线程同步的四种方式