public static Object[] remove(Object[] originalArray, int pos) {
    Object[] newArray = (Object[]) java.lang.reflect.Array
        .newInstance(originalArray.getClass().getComponentType(), originalArray.length - 1);

    // Test cases: (proof of correctness)
    // 1) A B C D E remove 0: expect "B C D E"
    // 2) A B C D E remove 2: expect "A B D E"
    // 3) A B C D E remove 4: expect "A B C D"

    // Copy everything before
    if (pos > 0) {
      System.arraycopy(originalArray, 0, newArray, 0, pos); // originalArray[pos - 1] is last
                                                            // element copied
    }

    // 1) A B C D E remove 0: no change, ". . . ."
    // 2) A B C D E remove 2: "A B" copied at beginning: "A B . ."
    // 3) A B C D E remove 4: "A B C D" copied (all done)

    // Copy everything after
    if (pos < originalArray.length - 1) {
      System.arraycopy(originalArray, pos + 1, // originalArray[pos + 1] is first element copied
          newArray, pos, // first position to copy into
          originalArray.length - 1 - pos);
    }

    // 1) A B C D E remove 0: "B C D E" copied into to position 0
    // 2) A B C D E remove 2: "D E" copied into position 2: "A B D E"
    // 3) A B C D E remove 4: no change
    return newArray;
  }
Remove element from an array. The element is removed at the specified position, and all
remaining elements are moved to the left.

@param originalArray array to remove from
@param pos position to remove
@return the new array
geode-core/src/main/java/org/apache/geode/internal/util/ArrayUtils.java