Java Reference
In-Depth Information
21.10. Wrapped Collections and the Collections Class
The Collections class defines a range of static utility methods that oper-
ate on collections. The utility methods can be broadly classified into two
groups: those that provide wrapped collections and those that don't. The
wrapped collections allow you to present a different view of an underly-
ing collection. There are three different views: a read-only view, a type-
safe view, and a synchronized view. The first two are discussed in this
section, synchronized wrappers are discussed later with the concurrent
collections. First we discuss the general utility methods.
21.10.1. The Collections Utilities
The Collections class defines many useful utility methods. You can find
the minimum and maximum valued elements in a collection:
public static <T extends Object & Comparable<? super T>> T
min(Collection<? extends T> coll)
Returns the smallest valued element of the collection based on
the elements' natural order.
public static <T> T min(Collection<? extends T> coll, Comparator<?
super T> comp)
Returns the smallest valued element of the collection according
to comp .
public static <T extends Object & Comparable<? super T>> T
max(Collection<? extends T> coll)
Returns the largest valued element of the collection based on
the elements' natural order.
 
Search WWH ::




Custom Search