Vector class containsAll(Collection> c)method example
Returns true if this Vector contains all of the elements in the specified Collection
Vector class containsAll(Collection> c)method example. This example shows you how to use containsAll(Collection> c)method.This method Returns true if this Vector contains all of the elements in the specified Collection
Here is the code:-
/*
* @Program that Returns true if this Vector contains all of the elements in
the specified Collection.
* ContainsAll.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class ContainsAll {
public static void main(String[] args) {
//creating a linkedlist
LinkedList l=new LinkedList();
l.add("Tikil");
l.add("Pinku");
l.add("Deepu");
l.add("Yogi");
//creating vector
Vector v= new Vector();
v.add("girish");
v.add("tewari");
//Returns true if this Vector contains all of the elements in the specified
//Collection.
boolean b=v.containsAll(l);
System.out.println("Does Vector v contains the elements of linkedlist : "+b);
//creating another vector
Vector v1= new Vector();
v1.add("Tikil");
v1.add("Pinku");
v1.add("Deepu");
v1.add("Yogi");
//Returns true if this Vector contains all of the elements in the specified
//Collection.
boolean b1=v1.containsAll(l);
System.out.println("Does Vector v1 contains the elements of linkedlist : "+b1);
}
} |
Output of the program:-
Does Vector v contains the elements of linkedlist : false
Does Vector v1 contains the elements of linkedlist : true |
|