Java Collection Tutorial - Java List.toArray()








Syntax

List.toArray() has the following syntax.

Object [] toArray()

Example

In the following code shows how to use List.toArray() method.

import java.util.Arrays;
import java.util.List;
/*  w w w.  ja  va 2s .c om*/
public class Main {
  public static void main(String args[]) {
    String[] a = new String[] { "a", "c", "b" };

    List<String> l = (Arrays.asList());
    String stuff[] = (String[]) l.toArray();
  }
}