Saturday, 13 December 2014

Java : Collection Framework : Vector (CopyInto method)


VectorExample.java
import java.util.Vector;

/*
 *  Example of copyInto(Object[] anArray) method. 
 */
public class VectorExample
{
    public static void main( String[] args )
    {
        Vector<Integer> vector = new Vector<Integer>();

        vector.add(20);
        vector.add(30);
        vector.add(40);
        vector.add(50);

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

        Integer[] integerArray = new Integer[vector.size()];

        /*
         * Copies the components of this vector into the specified array
         */

        vector.copyInto(integerArray);

        for( Integer value : integerArray )
        {
            System.out.println(value);
        }

    }
}

Output
vector  : [20, 30, 40, 50]

20
30
40
50

To Download VectorDemoCopyInto Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/VectorDemoCopyInto.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

    Google+ Followers

    Google+ Badge