Tuesday, 9 December 2014

Java : Collection Framework : Vector (Check empty or not)


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

VectorExample.java
import java.util.Vector;

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

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

        /*
         * Tests if this vector has no components.
         */

        boolean isEmpty = vector.isEmpty();

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

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

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

        /*
         * Tests if this vector has no components.
         */

        isEmpty = vector.isEmpty();

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

    }
}

Output
vector  : []
isEmpty  : true

vector  : [10, 20]
isEmpty  : false

To Download VectorDemoIsEmpty Project Click the below link

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