Click here to watch in Youtube :
https://www.youtube.com/watch?v=tKXaem3GFWc&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
Output
https://www.youtube.com/watch?v=tKXaem3GFWc&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
import java.util.Vector; /* * Example of Vector(int initialCapacity, int capacityIncrement) constructor. */ public class VectorExample { public static void main( String[] args ) { Vector<String> vector = new Vector<String>(5, 2); vector.add("Dave"); vector.add("Peter"); vector.add("Phil"); vector.add("Rohit"); vector.add("Virat"); System.out.println("vector : " + vector); System.out.println("vector size: " + vector.size()); System.out.println("vector capacity: " + vector.capacity() + "\n"); vector.add("Raj"); System.out.println("vector : " + vector); System.out.println("vector size: " + vector.size()); System.out.println("vector capacity: " + vector.capacity() + "\n"); } }
vector : [Dave, Peter, Phil, Rohit, Virat] vector size: 5 vector capacity: 5 vector : [Dave, Peter, Phil, Rohit, Virat, Raj] vector size: 6 vector capacity: 7
https://sites.google.com/site/javaee4321/java-collections/VectorDemoCapacityIncrement.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment