code: public int remove(int index) {
          if (index < 0 || index >= size) {
              throw new IndexOutOfBoundsException(String.valueOf(index));
          }
  
          int old = get(index);
          
          if (index == 0) {
              // data at the front
              System.arraycopy(data, 1, data, 0, size - 1);
          } else if (size - 1 == index) {
              // no copy to make, decrementing pos "deletes" values at
              // the end
          } else {
              // data in the middle
              System.arraycopy(data, index + 1, data, index, size - (index + 1));
          }
          
          size--;
          return old;
      }
docs: Removes the value at specified index from the list.
  
  @param index index of the element to remove.
  @return the value previously stored at specified index
  @throws IndexOutOfBoundsException if the index is out of range (index &lt; 0 || index &ge; size())