Java Program to convert Array to ArrayList
Program
import java.util.Arrays;
import java.util.List;
public class ArrayToArrayList
{
public static void main(String[] args)
{
String[] countryArray = {"India", "Australia", "France", "Germany"};
System.out.println("From array:");
for(int i = 0; i < countryArray.length; i++)
System.out.println(countryArray[i]);
System.out.println("From ArrayList:");
List countryList = Arrays.asList(countryArray);
System.out.println(countryList);
}
}
Output
From array:
India
Australia
France
Germany
From ArrayList:
[India, Australia, France, Germany]