Vector.setElementAt(E obj, int index) has the following syntax.
public void setElementAt(E obj, int index)
In the following code shows how to use Vector.setElementAt(E obj, int index) method.
/* w ww . j ava 2 s . c o m*/ import java.util.Vector; 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); vec.setElementAt(11,2); for (Integer number : vec) { System.out.println("Number = " + number); } } }
The code above generates the following result.