Java List.toArray(T[] a)

Syntax

List.toArray(T[] a) has the following syntax.

<T> T[] toArray(T[] a)

Example

In the following code shows how to use List.toArray(T[] a) method.


//www  .  j a  v  a2  s  . com
import java.util.Arrays;
import java.util.List;

public class Main {
  public static void main(String args[]) {
    String[] a = new String[] { "a", "c", "b" };

    List l = (Arrays.asList());
    String stuff[] = (String[]) l.toArray(new String[0]);
  }
}