3:44 pm - Thursday December 11, 3423

Vector Example Program for removeAllElements()

CANDID INDUSTRIAL TRAINING -- CHENNAI
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: removeAllElements() is used to Removes all components from this vector and sets its size to zero.
 */
import java.util.*;

public class DeeVectorRemoveAllElements {
	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);// to print the elements
		System.out.println("vector size is: " + v.size());// to print the
				                         //size	of the vector
		v.removeAllElements();// to remove all the elements and the
			             //vector  size is 0
		System.out.println("vector size is: " + v.size());// to print the
			                                    //size of vector
	}
}

output
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.