Vector.setSize(int newSize) has the following syntax.
public void setSize(int newSize)
In the following code shows how to use Vector.setSize(int newSize) method.
import java.util.Vector; //from w ww. j a v a 2 s . co m public class Main { public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(4); vec.add(3); vec.add(2); vec.add(1); // set new size to 8 vec.setSize(8); for (Integer number : vec) { System.out.println("Number = " + number); } } }
The code above generates the following result.