19.6. Collections Algorithms

The collections framework provides several high-performance algorithms for manipulating collection elements. These algorithms are implemented as static methods of class Collections (Fig. 19.7). Algorithms sort, binarySearch, reverse, shuffle, fill and copy operate on Lists. Algorithms min, max, addAll, frequency and disjoint operate on Collections.

Figure 19.7. Collections algorithms.
AlgorithmDescription
sortSorts the elements of a List.
binarySearchLocates an object in a List.
reverseReverses the elements of a List.
shuffleRandomly orders a List’s elements.
fillSets every List element to refer to a specified object.
copyCopies references from one List into another.
minReturns the smallest element in a Collection.
maxReturns ...

Get Java™ How to Program, Seventh 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.