Collections utilities
There are two classes with static methods handling collections that are very popular and helpful, as follows:
java.util.Collectionsorg.apache.commons.collections4.CollectionUtils
The fact that the methods are static means they do not depend on the object state, so they are also called stateless methods or utility methods.
java.util.Collections class
Many methods in the Collections class manage collections and analyze, sort, and compare them. There are more than 70 of them, so we won’t have a chance to talk about all of them. Instead, we are going to look at the ones most often used by mainstream application developers, as follows:
static copy(List<T> dest, List<T> src): This copies elements of thesrclist to thedestlist and preserves the order of elements and their position in the list. Thedestlist size has to be equal to, or bigger than, thesrclist size, otherwise a runtime exception is raised. Here...