code: public static <T> T[] toArray(List<T> list) {
          T[] toR = (T[]) Array.newInstance(list.get(0).getClass(), list.size());
          for (int i = 0; i < list.size(); i++) {
              toR[i] = list.get(i);
          }
          return toR;
      }
docs: Convert a List to a generic array
  
  @param list list collection
  @param <T>  generic
  @return array