Saturday, 13 December 2014

Java : Collection Framework : Vector (toArray Parameter)

Click here to watch in Youtube :
import java.util.Vector;

 *  Example of toArray(T[] a) method. 
public class VectorExample
    public static void main( String[] args )
        Vector<Integer> vector = new Vector<Integer>();


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

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

         * Returns an array containing all of the elements in this Vector in the
         * correct order; the runtime type of the returned array is that of the
         * specified array. If the Vector fits in the specified array, it is
         * returned therein. Otherwise, a new array is allocated with the
         * runtime type of the specified array and the size of this Vector.
         * If the Vector fits in the specified array with room to spare (i.e.,
         * the array has more elements than the Vector), the element in the
         * array immediately following the end of the Vector is set to null.
         * (This is useful in determining the length of the Vector only if the
         * caller knows that the Vector does not contain any null elements.)

        integerArray = vector.toArray(integerArray);

        for( Integer value : integerArray )


vector  : [20, 30, 40, 50]


To Download VectorDemoToArrayParam Project Click the below link

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