package cn.itcast_01;import java.util.arraylist;import java.util.collection;/* * Boolean addall (COLLECTION C): Adds an element of a collection * boolean removeall (collection c): Removes the element of a collection (is one or all) * boolean containsall (COLLECTION C): Determines whether the collection contains the specified collection element (one or all) * boolean retainall (collection c): Two elements of a collection? Where is the thought element, and what does the Boolean return mean? */public class collectiondemo2 {public static void main (String[] args) {// Create the collection 1collection c1 = new arraylist (); C1.add ("ABC1"); C1.add ("ABC2"); C1.add ("ABC3"); C1.add (" ABC4 ");// Create Collection 2collection c2 = new arraylist ();//c2.add (" ABC1 ");//c2.add (" ABC2 ");// C2.add ("ABC3"),//c2.add ("ABC4"), C2.add ("Abc5"), C2.add ("Abc6"), C2.add ("ABC7");// boolean addall ( COLLECTION C): Add an element of a collection// system.out.println ("AddAll:" + c1.addall (C2)); C1 change, C1 C2 ABC4, Abc5,abc6,abc7 added (this shows that you can add a duplicate)//boolean removeall (collection c): Removes the element of a collection (is one or all)//returns True whenever an element is removed. System.out.println ("RemoveAll:" +c1.removeall (C2)); Who changed who, the results show as TRUE,    C1:[ABC1,ABC2,ABC3] c2:[abc4,abc5,abc6,abc7] This shows that removing one is called removing (the ABC4 in the C1 collection is gone)//boolean containsall (COLLECTION C): Determines whether the collection contains the specified set element (is one or all)//only contains all elements, called contains// SYSTEM.OUT.PRINTLN (" Containsall: "+c1.containsall (C2));//boolean retainall (collection c): Two elements of a collection? Where is the thought element? What does the Boolean return mean?//Assume there are two sets, A, B. A to B intersection, the final result is saved in a, B unchanged. The return value indicates whether a has changed. System.out.println ("Retainall:" +c1.retainall (C2)); SYSTEM.OUT.PRINTLN ("C1:"  + C1); System.out.println ("C2:"  + C2);}}
Note that the methods above call themselves must be collection objects, and the method is a collection object, so start by creating two collection objects first
Collection interface member Methods
Boolean AddAll (Collection c)
Boolean RemoveAll (Collection c)
Boolean containsall (Collection c)
Boolean retainall (Collection c)
This article from "GD" blog, reproduced please contact the author!
Collection Framework (Advanced functional Testing of the collection collection)