Java List to Array asArray(List list)

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

Description

Converts a list to an array of the same type.

License

Open Source License

Parameter

Parameter Description
T Type of list elements
list Basic list for operation

Return

An array of the same type containing all elements of list

Declaration

public static <T> T[] asArray(List<T> list) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/*from   w  w w.j  ava 2  s. co  m*/
     * Converts a list to an array of the same type.
     * 
     * @param <T>
     *            Type of list elements
     * @param list
     *            Basic list for operation
     * @return An array of the same type containing all elements of
     *         <code>list</code>
     */
    public static <T> T[] asArray(List<T> list) {
        return (T[]) list.toArray();
    }
}

Related

  1. asArray(Collection list)
  2. asArray(List values)
  3. asArray(List indices)
  4. asArray(List list)
  5. asArrayList(E first, E... other)
  6. asArrayList(T... a)
  7. asBooleanArray(List list)
  8. asByteArray(final List l)