code: public static <S extends Object, T extends S> T[] copy (
          S[] values, T[] store)
      {
          @SuppressWarnings("unchecked")
          T[] dest = (store.length >= values.length) ? store :
              (T[])Array.newInstance(store.getClass().getComponentType(), values.length);
          System.arraycopy(values, 0, dest, 0, values.length);
          return dest;
      }
docs: Similar to {@link Collection#toArray}, this method copies the contents
  of the first parameter to the second, creating a new array of the same
  type if the destination array is too small to hold the contents of the
  source.