public
synchronized int size()
Returns the
number of components in this vector.
import java.util.*; class VectorSize{ public static void main(String args[]){ Vector<Integer> myVector; myVector = new Vector<> (); System.out.print("Size of Vector is "); System.out.println(myVector.size()); /* Add Elements to myVector */ myVector.add(10); myVector.add(20); System.out.print("Size of Vector is "); System.out.println(myVector.size()); } }
Output
Size of Vector is 0 Size of Vector is 2
No comments:
Post a Comment