Monday, 8 December 2014

Java : Collection Framework : Vector (How to add elements)


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

VectorExample.java
import java.util.Vector;

/*
 *  Example of add(E e) method 
 */
public class VectorExample
{

    public static void main( String[] args )
    {
        /*
         * Constructs an empty vector so that its internal data array has size
         * 10 and its standard capacity increment is zero.
         */
        Vector<Integer> vector = new Vector<>();

        /*
         * Appends the specified element to the end of this Vector.
         */
        vector.add(100);
        vector.add(200);
        vector.add(300);

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

    }
}

Output
vector  : [100, 200, 300]



To Download VectorDemoAdd Project Click the below link

https://sites.google.com/site/javaee4321/java-collections/VectorDemoAdd.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