There are two classes with static methods handling collections that are very popular and helpful:
- java.util.Arrays
- org.apache.commons.lang3.ArrayUtils
We will briefly review each of them.
There are two classes with static methods handling collections that are very popular and helpful:
We will briefly review each of them.
We have already used the java.util.Arrays class several times. It is the primary utility class for arrays management. This utility class used to be very popular because of the asList(T...a) method. It 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");
It is still a popular way of creating a modifiable list. We used it, too...