Here you can find the source of toArray(List> list)
Parameter | Description |
---|---|
list | a parameter |
public static Object[] toArray(List<?> list)
//package com.java2s; import java.util.List; public class Main { /**/* w w w.j ava2 s.c om*/ * list to array * * @param list * @return if list is null return null */ public static Object[] toArray(List<?> list) { if (null == list || list.isEmpty()) { return null; } Object[] arr = new Object[list.size()]; for (int i = 0; i < list.size(); i++) { arr[i] = list.get(i); } return arr; } public static boolean isEmpty(List<?> list) { return null == list || list.isEmpty(); } }