code: public static <T> T[] toArray(List<T> list) {
      return toArray(getClass(list.get(0)), list);
    }
docs: Converts the given <code>List&lt;T&gt;</code> to a an array of
  <code>T[]</code>.
  @param list the list to convert
  @throws ArrayIndexOutOfBoundsException if the list is empty.
  Use {@link #toArray(Class, List)} if the list may be empty.