package nilpointer.net;
import java.util.ArrayList;
public class Demo {
public static void main(String[] args) {
ArrayList<String> names = new ArrayList<String>();
names.add("Name 1");
names.add("Name 2");
names.add("Name 3");
names.add("Name 4");
String[] array = names.toArray(new String[names.size()]);
System.out.println("Output:");
for (String name : array) {
System.out.println(name);
}
}
}
Output
Output:
Name 1
Name 2
Name 3
Name 4