Arrays utilities
There are two classes with static methods handling collections that are very popular and helpful, as follows:
java.util.Arraysorg.apache.commons.lang3.ArrayUtils
We will briefly review each of them.
java.util.Arrays class
We have already used the java.util.Arrays class several times. It is the primary utility class for array 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 and is shown in the following snippet:
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. However, after a List.of() factory method was introduced, the Arrays class declined substantially.
Nevertheless, if you need to manage arrays, then the Arrays class may...