Replace element in a vector

ReturnMethodSummary
Eset(int index, E element)Replaces the element at the specified position in this Vector with the specified element.
voidsetElementAt(E obj, int index)Sets the component at the specified index of this vector to be the specified object.

import java.util.Arrays;
import java.util.Enumeration;
import java.util.Vector;

public class Main{

  public static void main(String args[]) {

    Vector v = new Vector();

    v.add("java2s.com");
    v.add("A");
    v.add("B");
    
    v.set(1, "j a v a 2 s . c o m");
    System.out.println(v);
  }
}

The output:


[java2s.com, j a v a 2 s . c o m, B]
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.