Java tutorial
import java.util.Vector; public class Main { public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(0, 4); vec.add(1, 3); vec.add(2, 2); vec.add(3, 1); for (Integer number : vec) { System.out.println("Index :" + vec.indexOf(number) + " Number: " + number); } // added new number 10 at 3rd position/index vec.add(3, 10); for (Integer number : vec) { System.out.println("Index :" + vec.indexOf(number) + " Number: " + number); } } }