Tuesday, 9 December 2014

Java : Collection Framework : Vector (Iterator)


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

VectorExample.java
import java.util.Iterator;
import java.util.Vector;

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

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

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

        /*
         * Returns an iterator over the elements in this list in proper
         * sequence.
         */

        Iterator<Integer> iterator = vector.iterator();

        while( iterator.hasNext() )
        {
            Integer value = iterator.next();
            System.out.println(value);
        }

    }
}

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

10
20
30
40

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