Thursday 11 December 2014

Java : Collection Framework : Vector (Constructor Accepts Collection)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=6nau6vADths&list=UUhwKlOVR041tngjerWxVccw

VectorExample.java
import java.util.ArrayList;
import java.util.Vector;

/*
 *  Example of Vector(Collection<? extends E> c) Constructor. 
 */
public class VectorExample
{
    public static void main( String[] args )
    {
        ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("Dave");
        arrayList.add("Peter");
        arrayList.add("Phil");

        System.out.println("arrayList : " + arrayList);

        /*
         * Constructs a vector containing the elements of the specified
         * collection, in the order they are returned by the collection's
         * iterator.
         */
        Vector<String> vector = new Vector<String>(arrayList);

        System.out.println("vector : " + vector);

    }
}

Output
arrayList : [Dave, Peter, Phil]
vector : [Dave, Peter, Phil]

To Download VectorDemoConsAcceptsCollection Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/VectorDemoConsAcceptsCollection.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment