import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class StringArrayToList {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] numbers = new String[] { "one", "two", "three"};
List list = (List) Arrays.asList(numbers);
System.out.println("String array converted to List");
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
List anotherList = new ArrayList();
Collections.addAll(anotherList, numbers);
System.out.println(anotherList);
}
}
Console:
String array converted to List
one
two
three
[one, two, three]