code: public static <T> T[] toArray(Class<T> c, List<T> list)
    {
      @SuppressWarnings("unchecked")
      T[] ta= (T[])Array.newInstance(c, list.size());
  
      for (int i= 0; i<list.size(); i++)
        ta[i]= list.get(i);
      return ta;
    }
docs: Converts the given <code>List&lt;T&gt;</code> to a an array of
  <code>T[]</code>.
  @param c the Class object of the items in the list
  @param list the list to convert