import java.util.Arrays;
public class Main {
public static int[] removeSubarray(int[] array, int start, int end) {
int[] firstPart = Arrays.copyOfRange(array, 0, start);
int[] secondPart = Arrays.copyOfRange(array, end + 1, array.length);
// Combine the two parts
int[] result = new int[firstPart.length + secondPart.length];
System.arraycopy(firstPart, 0, result, 0, firstPart.length);
System.arraycopy(secondPart, 0, result, firstPart.length, secondPart.length);
return result;
}
public static void main(String[] args) {
int[] array = {1, 2, 3, 4, 5, 6, 7, 8};
int start = 2, end = 4;
int[] result = removeSubarray(array, start, end);
System.out.println(Arrays.toString(result));
}
}
/*
run:
[1, 2, 6, 7, 8]
*/