Create a List using Arrays.asList in Java 8
February 7, 2015 Leave a comment
Java 8 has a number of new methods on Collections. One such utility method is the static asList method with which you can quickly create a List of T.
Here’s how it works for a List of integers:
List<Integer> asList = Arrays.asList(1,2,3,4);
…and for a List of strings:
List<String> asList = Arrays.asList("hello", "my", "dear", "world");
View all posts related to Java here.