+ 1

what is the difference between size() and capacity() from vector class

11th Jul 2016, 7:49 PM
Umesh Langade
Umesh Langade - avatar
2 odpowiedzi
+ 1
size is the number of elements which is currently hold. capacity is the number of element which can maximum hold.
11th Jul 2016, 10:59 PM
Randhir Raj
0
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. More.... http://net-informations.com/java/cjava/size.htm
13th Sep 2017, 11:09 AM
rahul kumar
rahul kumar - avatar