Similar to the trim utility method for Array. below is another simple but useful Java Collection Utility/Util method, which can be used to trim/remove all null Object values in a Collection object. Doing this would eliminate a null check on every element in collection. This method returns null value if the input Collection itself is null. We can call this as trim of Collection, as it will return all not null objects in the result(trimming the size of Collection).
Continue Reading
Java Collection Utility methods - Trim/notNull for Collection
Tags