Java 9 introduced new factory methods for lists, List.of
:
List<String> strings = List.of("first", "second");
What’s the difference between the previous and the new option? That is, what’s the difference between this:
Arrays.asList(1, 2, 3);
and this:
List.of(1, 2, 3);