import java.util.Vector; public class VectorExample { public static void main(String[] args) { Vectorfruits = new Vector (); fruits.add("Apple"); fruits.add("Orange"); fruits.add("Banana"); System.out.println(fruits); // Output: [Apple, Orange, Banana] } }
import java.util.Vector; public class VectorExample { public static void main(String[] args) { VectorIn this example, we create a Vector of Integers and add some numbers to it. We then add the number 15 at index 1 in the Vector and print the contents of the Vector. Package library: java.util.numbers = new Vector (); numbers.add(10); numbers.add(20); numbers.add(30); numbers.add(1, 15); System.out.println(numbers); // Output: [10, 15, 20, 30] } }