VideosMy ProjectsProgramming BlogGallery
  1. Home
  2. Blog
  3. All the ways to create a List in Java
Programming Blog

Atom/RSS Feed

java

All the ways to create a List in Java

java

The various ways you can create a list in Java

No initial item

List<Integer> list = Collections.emptyList();

Single initial item

List<Integer> list = Collections.singletonList(1);

Many initial items

List<Integer> list = Arrays.asList(1,2,3);
Join my mailing list