can we convert arraylist to array in java code example
Example 1: java arraylist to array
List<String> list = new ArrayList<>();
list.add("a");
list.add("ab");
list.add("abc");
list.add("abcd");
// convert
String[] array = list.toArray();
Example 2: array to arraylist
new ArrayList<>(Arrays.asList(array));