class _Arrays {

    public static <T> T[] removeByIndex(T[] array, int index) {
        if(array==null || array.length<1) {
            throw new IllegalArgumentException("Array must be of lenght 1 or larger.");
        }
        if(index<0 || index>=array.length) {
            val msg = String.format("Array index %d is out of bounds [0, %d]", index, array.length-1);
            throw new IllegalArgumentException(msg);
        }
        final T[] result = Arrays.copyOf(array, array.length - 1);
        // copy the elements from index + 1 till end 
        // from original array to the new array 
        val remaining = result.length - index;
        System.arraycopy(array, index+1, result, index, remaining);
        return result;
    }

}