3:11 pm - Tuesday November 23, 6506

Vector Example Program for size()

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

// Vector Example Program for size()
/**
@author: candidjava.com
@description: This program gives the number of elements in the Vector.
*/

import java.util.*;

public class Size {
public static void main(String[] args) {
Vector v = new Vector(); // Creating a new vector
// adding Elements to the vector
v.add("Love");
v.add(4);
v.add('t');
for (Object o : v) {
System.out.println(o);
}
System.out.println();
int i = v.size(); // Get the size of the vector
System.out.println("The num of elements in this vector is:  " + i);
}
}


output:
Love
4
t

The num of elements in this vector is:  3

Filed in: Z-A All Java Codes

Comments are closed.