Collection: addAll(Collection c) Adds every element of c to this collection : Collection « Utility Classes « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Utility Classes » Collection 
8.11.3.Collection: addAll(Collection c) Adds every element of c to this collection
import java.util.ArrayList;
import java.util.Collection;

public class MainClass {
  public static void main(String[] argv) {
    Collection collection1 = new ArrayList();
    collection1.add("1");

    Collection collection2 = new ArrayList();
    collection2.add("2");

    collection1.addAll(collection2);

    System.out.println(collection1);
  }
}
[1, 2]
8.11.Collection
8.11.1.The central interfaces of he Collections Framework are
8.11.2.Collection: add(Object x) Adds x to this collection
8.11.3.Collection: addAll(Collection c) Adds every element of c to this collection
8.11.4.Collection: clear() Removes every element from this collection
8.11.5.Collection: contains(Object x) Returns true if this collection contains x
8.11.6.Collection: containsAll(Collection c) Returns true if this collection contains every element of c
8.11.7.Collection: isEmpty() Returns true if this collection contains no elements
8.11.8.iterator() Returns an Iterator over this collection (see below)
8.11.9.Collection: remove(Object x) Removes x from this collection
8.11.10.Collection: removeAll(Collection c) Removes every element in c from this collection
8.11.11.Collection: retainAll(Collection c) Removes from this collection every element that is not in c
8.11.12.Collection: size() Returns the number of elements in this collection
8.11.13.Collection: toArray() Returns an array containing the elements in this collection
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.