Convert array to list
static<T> List<T> asList(T... a)
- Returns a fixed-size list backed by the specified array.
Create List from Object Array
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
String[] strArray = new String[] { "java2s.com", "A", "B", "C", "D" };
List list = Arrays.asList(strArray);
System.out.println(list);
}
}
The output:
[java2s.com, A, B, C, D]