9:49 am - Wednesday December 19, 2018

Vector Example Program for capacity()

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
/*Program Name: Vector Example Program for capacity()*/
/**
*@Author: Candidjava.com
*@Description:Vector Example Program for capacity()
Method is used to Returns the current capacity of this vector.
*/
import java.util.*;

public class CollectionVector
{
public static void main(String args[])
{
Vector v1=new Vector(); // creating constructor without any argument. Default size is 10.
System.out.println("Vector Capacity of v1 is:" +v1.capacity()); // printing the result.
Vector v2=new Vector(2); // creating constructor with 1 argument. Size increases depends upon the entries.
System.out.println("Vector Capacity of v2 is:" +v2.capacity()); // printing the result.

}
}

Output:

Vector Capacity of v1 is:10
Vector Capacity of v2 is:2

Filed in: Z-A All Java Codes

Comments are closed.