import java.util.Vector; public class VectorExample { public static void main(String[] args) { VectorIn this example, we create a Vector of type String and add three fruits to it. Then we use the setElementAt() method to replace the second element (banana) with "pear". The output will be [apple, pear, cherry]. Package library: java.utilvector = new Vector<>(); vector.add("apple"); vector.add("banana"); vector.add("cherry"); vector.setElementAt("pear", 1); System.out.println(vector); } }