# Size of Vector

It is very important to know the size of Vector as it is required in most of the times while coding

We have size() method in Vector class which helps us to determine the size of Vector

Size is the number of elements in that Vector

1. public int size();
`public int size();`

Example :

1. import java.util.*;
2.
3. public class VectorSize {
4.     public static void main(String[] args) {
5.     Vector<Integer> vector = new Vector<Integer>();
12.         System.out.println("Initial Size of Vector: "+vector.size());
13.         vector.remove(1);
14.         vector.remove(2);
15.         System.out.println("Size after removing 2 elements: "+vector.size());
16.         System.out.println("Final Vector after removal of 2 elements: ");
17.         for(int ele: vector){
18.             System.out.println(ele);
19.         }
20.     }
21. }
```import java.util.*;

public class VectorSize {
public static void main(String[] args) {
Vector<Integer> vector = new Vector<Integer>();
System.out.println("Initial Size of Vector: "+vector.size());
vector.remove(1);
vector.remove(2);
System.out.println("Size after removing 2 elements: "+vector.size());
System.out.println("Final Vector after removal of 2 elements: ");
for(int ele: vector){
System.out.println(ele);
}
}
}```
`Note : Size just tells how many elements are present in the Vector`

Don’t get confuse size with capacity in the Vector, we will talk about capacity separately

Just remember Size() returns number of elements present in Vector

Remember size() is a method , not a variable in the Vector class. 