Tuesday 9 December 2014

Java : Collection Framework : Vector (Check Group of Objects exist or not)


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

VectorExample.java
import java.util.ArrayList;
import java.util.Vector;

/*
 *  Example of containsAll(Collection<?> c) 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");

        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        arrayList.add(10);
        arrayList.add(30);

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

        /*
         * Returns true if this Vector contains all of the elements in the
         * specified Collection.
         */
        boolean isExist = vector.containsAll(arrayList);

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

    }
}

Output
vector  : [10, 20, 30]

arrayList  : [10, 30]

isExist : true

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