Android examples for java.lang:array
to Array via Array.newInstance
import java.lang.reflect.Array; import java.util.List; public class Main{ public static <T> T[] toArray(List<T> list, Class<T> clazz) { @SuppressWarnings("unchecked") T[] result = (T[]) Array.newInstance(clazz, list.size()); for (int i = 0; i < list.size(); i++) { result[i] = list.get(i);//from ww w .j av a 2s . co m } return result; } }