code: @SuppressWarnings("unchecked")
    public static <T> T[] insert(T element, T[] array, int index) {
  
      Assert.notNull(array, "Array is required");
  
      assertThat(index).throwing(new ArrayIndexOutOfBoundsException(
        String.format("[%1$d] is not a valid index [0, %2$d] in the array", index, array.length)))
          .isGreaterThanEqualToAndLessThanEqualTo(0, array.length);
  
      Class<?> componentType = array.getClass().getComponentType();
  
      componentType = defaultIfNull(componentType, ObjectUtils.getClass(element));
      componentType = defaultIfNull(componentType, Object.class);
  
      T[] newArray = (T[]) Array.newInstance(componentType, array.length + 1);
  
      if (index > 0) {
        System.arraycopy(array, 0, newArray, 0, index);
      }
  
      newArray[index] = element;
  
      if (index < array.length) {
        System.arraycopy(array, index, newArray, index + 1, array.length - index);
      }
  
      return newArray;
    }
docs: Inserts element into the array at index.
  
  @param <T> Class type of the elements in the array.
  @param element element to insert into the array.
  @param array array in which the element is inserted.
  @param index an integer indicating the index into the array at which the element will be inserted.
  @return a new array with element inserted at index.
  @throws IllegalArgumentException if array is null.
  @throws ArrayIndexOutOfBoundsException if given index is not a valid index in the array.
  @see #prepend(Object, Object[])
  @see #append(Object, Object[])