Java tutorial
import java.util.Arrays; public class Main { public static void main(String[] argv) { String[] oldArray = new String[] { "a", "b", "c", "d" }; int index = Arrays.binarySearch(oldArray, "e"); if (index < 0) { int insertIndex = -index - 1; String[] newArray = new String[oldArray.length + 1]; System.arraycopy(oldArray, 0, newArray, 0, insertIndex); System.arraycopy(oldArray, insertIndex, newArray, insertIndex + 1, oldArray.length - insertIndex); newArray[insertIndex] = "e"; oldArray = newArray; } } }