Java tutorial
//package com.java2s; import java.lang.reflect.Array; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <T> T[] listToArray(List<T> list) { if (list == null) { return null; } T[] tArr = (T[]) Array.newInstance(list.get(0).getClass(), list.size()); return list.toArray(tArr); } }