SiteMap  | About    

capacity() and size() of Vector in Java

The difference between capacity() and size() in java.util.Vector is that the size() is the number of elements which is currently hold and capacity() is the number of element which can maximum hold. A Vector is a dynamically growable data structure, and it would reallocate its backing array as necessary. Thus, there is no final capacity, but you can set what its initial value is. A Vector defaults to doubling the size of its array.



Vector in Java

Java Vectors are commonly used instead of arrays , because they expand automatically when new data is added to them. That means the Vector instances, like linked-lists , can grow dynamically . However, the size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created. More about.... Vector in Java (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.