import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ArrayListToArray {
public static void main(String args[]) {
List strings = new ArrayList();
strings.add("First Name");
strings.add("Last Name");
strings.add("Age");
Object[] objArray = (Object[]) strings.toArray();
String[] stringArray = Arrays.copyOf(objArray, objArray.length, String[].class);
for (int i = 0; i < stringArray.length; i++) {
System.out.println("Value : " + stringArray[i]);
}
}
}
Thursday, May 16, 2013
How to convert ArrayList to Array
Tags
# Core Java
# Java Collection
About Unknown
Kumar Bhatia is a technical resource working with Accenture and owns this blog on Java.
Java Collection
Labels:
Core Java,
Java Collection
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment