public class ConvertArrayList2Arrays {
public static void main(String[] args) { List<String> list = new ArrayList<String>();
list.add("Blobbo");
list.add("Cracked");
list.add("Dumbo");
// Now if you want to store the list in an array, you can do one of these
Object[] arrOfObjects = new Object[]{list.size()};// Convert list items in an Object type of array Object[] arrOfObjects = list.toArray();// Convert list items in an Generic (String) type of array
String[] arrayOfStrings = list.toArray(new String[list.size()]); }}
Posted in: