how to save the entries of arraylist to array in java code example
Example 1: how to convert a collection to array in java
List<String> list = new ArrayList<String>(); // Original list
String[] arr = list.toArray(new String[list.size()]); // toArray function with array to be populated by this list as an argument.
Example 2: convert list to array in java
Integer[] arr = new Integer[al.size()];
arr = al.toArray(arr);