public static void insert(int[] values, int num) throws RuntimeException { //First, create a copy copy = new int[values.length]; for (int i = 0; i= values[i]) { indexToInsert = i; break; } } //Move everything else after that one unit to the right //(omit last one, as required in the labtest) for (int i = (indexToInsert); i<(values.length-1); i++) { values[i+1] = copy[i]; } //Now that there is space, insert the number values[indexToInsert] = num; } }