Online Java Compiler By
JavaTpoint.com
import java.util.*; public class VectorSetSizeExample3 { public static void main(String arg[]) { //Create an empty vector Vector
vec = new Vector<>(); //Add elements in the vector vec.add(10); vec.add(20); vec.add(30); //Set the new size of the vector vec.setSize(-15); //Displaying the vector element System.out.println("Vector element after setSize(): " +vec); } }
Output