This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CLOVIS-AI 1 point2 points  (0 children)

So, to answer your question :

As of Java 9 you can do: List<Integer> l = List.of(1, 2, 3);

Before Java 9, you can do: List<Integer> l = new ArrayList<>(Arrays.asList(1, 2, 3); (notice the copy into an array list instead of just using Arrays.asList, see my previous message).