This documentation is archived and is not being maintained.

Vector.addAll Method (Collection)

Visual Studio 2005

Adds all the elements in the collection to the vector. The vector is automatically grown if there is insufficient room to add the elements.

Package: java.util

Assembly: vjslib (in vjslib.dll)

public synchronized boolean addAll(
    java.util.Collection c);



The elements to be added to the collection. Only a shallow copy of these elements is performed.

true if all the elements were successfully added to the vector; false otherwise.

The following example adds all the elements of a LinkedList object into a Vector object.

// vector_addall.jsl

import java.util.*;

public class Program
    public static void main(String[] args)
        // Create a LinkedList and add three elements to it.
        LinkedList ll = new LinkedList();
        ll.add("Linked List Element 1");
        ll.add("Linked List Element 2");
        ll.add("Linked List Element 3");

        // Create a Vector containing the same elements as the
        // LinkedList.
        Vector v = new Vector(ll);

        // Display the contents of the Vector.
        Enumeration vEnum = v.elements();
        while (vEnum.hasMoreElements())

Linked List Element 1
Linked List Element 2
Linked List Element 3