Create a List using Arrays.asList in Java 8

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.

Advertisement

About Andras Nemes
I'm a .NET/Java developer living and working in Stockholm, Sweden.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

Bite-size insight on Cyber Security for the not too technical.

%d bloggers like this: