Monday, 8 December 2014

Java : Collection Framework : Vector (Clear All Elements)



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

VectorExample.java
import java.util.Vector;

/*
 *  Example of clear() method 
 */
public class VectorExample
{

    public static void main( String[] args )
    {
        Vector<Integer> vector = new Vector<>();

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

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

        /*
         * Removes all of the elements from this Vector. The Vector will be
         * empty after this call returns (unless it throws an exception).
         */
        vector.clear();

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

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

vector  : []



To Download VectorDemoClear Project Click the below link

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