Java List to Array toArray(List list)

Here you can find the source of toArray(List list)

Description

list to array

License

Open Source License

Parameter

Parameter Description
list a parameter

Return

if list is null return null

Declaration

public static Object[] toArray(List<?> list) 

Method Source Code

//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();
    }
}

Related

  1. toArray(List list)
  2. toArray(List list)
  3. toArray(List list)
  4. toArray(List list, Object array[], int start, int end)
  5. toArray(List lista)
  6. toArray(List data)
  7. toArray(List list)
  8. toArray(List list)
  9. toArray(List list)