Sadly as far as I'm aware something like that can't be done in a single operation. The best I was able to come up with is to create a result array. Then you copy to it first part of arr2, whole arr1 and finally second part of arr2. In the end whole method would look like so:
private static int[] insertArrayAtPosition(int[] arr1, int[] arr2, int insertPos){
int[] result = new int[arr1.length + arr2.length];
System.arraycopy(arr2, 0, result, 0, insertPos);
System.arraycopy(arr1, 0, result, insertPos, arr1.length);
System.arraycopy(arr2, insertPos, result, insertPos + arr1.length, arr2.length - insertPos);
return result;
}
And then you can call it like so:
public static void main(String args[]) {
int[] arr1 = new int[] {3, 4, 5};
int[] arr2 = new int[] {8, 7, 1, 0};
int[] result = insertArrayAtPosition(arr1, arr2, 2);
System.out.println(Arrays.toString(result));
}
Edit: Milgo's solution looks much better. However, mine allows to insert one array into another at specific position after they are already created. Which one to use depeds on the usecase.
ArrayUtils.addAll. I need the array to be in a specific position in the second array.