June 2018
Beginner
722 pages
18h 47m
English
We have used the class java.util.Arrays already several times. It is the primary tool for array management. But, it used to be very popular with those who use collections too because the method asList(T...a) was the most compact way of creating and initializing a collection:
List<String> list = Arrays.asList("s0", "s1");Set<String> set = new HashSet<>(Arrays.asList("s0", "s1");
But after a factory method, of(), was introduced in each of the collections, the popularity of the Arrays class dropped substantially. The following is a more natural way to create a collection:
List<String> list = List.of("s0", "s1");Set<String> set = Set.of("s0", "s1");
This collection's objects are immutable. But if a mutable one is needed, ...
Read now
Unlock full access