Java tutorial
//package com.java2s; import java.util.Vector; public class Main { public static <K> K setElementAt(Vector<K> vec, int index, K value) { K retVal; if (vec.size() <= index) { vec.setSize(index + 10); retVal = null; } else retVal = vec.elementAt(index); vec.setElementAt(value, index); return retVal; } }