Collection Utilities and Wrappers

Besides the methods already introduced, the Collections class provides a number of other useful support functions. This section outlines some of the more commonly used utilities and the Collections methods that wrap the general-purpose collection implementations with special features.

Utility Methods and Fields

In addition to searching for a specific object in a collection, you can use Collections to locate the maximum or minimum object based either on natural ordering or a Comparator:

public static Object max(Collection coll)
public static Object max(Collection coll, Comparator c)
public static Object min(Collection coll)
public static Object min(Collection coll, Comparator c)

You can reorder the elements ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.