code: @SuppressWarnings("unchecked")
      public static <T> T[] toArray(List list, Class<T> tClass) {
          Object arrayObject = Array.newInstance(tClass, list.size());
          for (int i = 0; i < list.size(); i++) {
              Array.set(arrayObject, i, list.get(i));
          }
          return (T[]) arrayObject;
      }
docs: convert list to an array.
  
  @param list   the given list
  @param tClass the element class
  @param <T>    the element type
  @return the newly created array containing all the elements in the list.