<collection>
Collection collection = new HashSet();
boolean containsElement = collection.contains("an element");
Collection elements = new HashSet();
boolean containsAll = collection.containsAll(elements);
Collection colA = [A,B,C]
Collection colB = [1,2,3]
Collection target = [];
target.addAll(colA); //target now contains [A,B,C]
target.addAll(colB); //target now contains [A,B,C,1,2,3]
target.retainAll(colB); //target now contains [1,2,3]
target.removeAll(colA); //nothing happens - already removed
target.removeAll(colB); //target is now empty.
沒有留言:
張貼留言