11:00 pm - Friday March 22, 2019

Vector Example Program for removeAll(Collection c)

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
@author: candidjava
@description: removeAll(Collection c) is used to Removes from this Vector all of its elements that are contained in the specified Collection.
import java.util.*;
public class DeeVectorRemoveAll
public static void main(String []args)
Vector v=new Vector();//create the vector
v.add(1); //add the elements
v.add(2); //add the elements
v.add(3); //add the elements
v.add(4); //add the elements
v.add(5); //add the elements
System.out.println("number list: "+v);//print the element list
System.out.println("vector size is: "+v.size());//print the size of the vector
v.removeAll(v);//to remove all the elements
System.out.println("number list: "+v);//to print the element list
System.out.println("vector size is: "+v.size());//to print the size of vector

number list: [1, 2, 3, 4, 5]
vector size is: 5
number list: []
vector size is: 0

Filed in: Z-A All Java Codes

Comments are closed.