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.
// Convert an Array into Collection in Java
// import java util library
import java.util.*;
// class for writing logic of the problem
public class ArrayToCollection {
public static void main(String args[])
{
// array input
String playersArray[]
= { "Virat", "Sachin", "Rohit", "Bumrah" };
// printing input elements for comparison
System.out.println("Array input: "
+ Arrays.toString(playersArray));
// converting array into Collection
// with asList() function
List playersList = Arrays.asList(playersArray);
// print converted elements
System.out.println("Converted elements: "
+ playersList);
}
}