Array to List
In this chapter you will learn:
Convert array to list
static<T> List<T> asList(T... a)
Returns a fixed-size list backed by the specified array.
The following code creates List from Object Array.
import java.util.Arrays;
import java.util.List;
//from j ava2s.co m
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:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Array