当前位置 : 主页 > 编程语言 > c++ >

org.apache.commons.collections4.CollectionUtils 操作集合

来源:互联网 收集:自由互联 发布时间:2021-06-30
org.apache.commons.collections4.CollectionUtils 操作集合 String[] arrayA = new String[] { "1", "2", "3", "3", "4", "5" }; String[] arrayB = new String[] { "3", "4", "4", "5", "6", "7" }; List a = Arrays.asList(arrayA); List b = Arrays.a
org.apache.commons.collections4.CollectionUtils 操作集合
String[] arrayA = new String[] { "1", "2", "3", "3", "4", "5" };
        String[] arrayB = new String[] { "3", "4", "4", "5", "6", "7" };
        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: " + a.toArray()); System.out.println("B: " + b.toArray()); System.out.println("--------------------------------------------"); System.out.println("Union(A, B): " + union.toArray());//并集 System.out.println("Intersection(A, B): " + intersection.toArray());//交集 System.out.println("Disjunction(A, B): " + disjunction.toArray());//交集的补集 System.out.println("Subtract(A, B): " + subtract.toArray());//集合想减,A-B
          
         
        
       
      
     
    
   
  
 
上一篇:sc-app-fwt
下一篇:m2 setting
网友评论