code: @SuppressWarnings("unchecked")
      public static <T> T[] newArray(final T[] oldElements, final int length)
      {
          return (T[])Array.newInstance(oldElements.getClass().getComponentType(), length);
      }
docs: Allocate a new array of the same type as another array.
  
  @param oldElements on which the new array is based.
  @param length      of the new array.
  @param <T>         type of the array.
  @return the new array of requested length.