code: public static <T> T[] append(T[] array, int currentSize, T element) {
          assert currentSize <= array.length;
  
          if (currentSize + 1 > array.length) {
              @SuppressWarnings("unchecked")
              T[] newArray = (T[]) new Object[growSize(currentSize)];
              System.arraycopy(array, 0, newArray, 0, currentSize);
              array = newArray;
          }
          array[currentSize] = element;
          return array;
      }
docs: Appends an element to the end of the array, growing the array if there is no more room.
  
  @param array       The array to which to append the element. This must NOT be null.
  @param currentSize The number of elements in the array. Must be less than or equal to
  array.length.
  @param element     The element to append.
  @return the array to which the element was appended. This may be different than the given
  array.