bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Collections Class Methods

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Java Collections Class Methods?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

Collections Methods

The Collections class (in java.util ) contains several useful methods for working with collections like ArrayList , HashSet , and HashMap .

MethodDescriptionReturn Type
sort()Sorts the list in ascending order (according to natural ordering)void
binarySearch()Searches for a key in a sorted list and returns its index (otherwise < 0 )int
reverse()Reverses the order of elements in a listvoid
reverseOrder()Returns a comparator that imposes the reverse of natural orderingComparator
shuffle()Randomly permutes the elements of a listvoid
swap()Swaps the elements at the specified positions in a listvoid
frequency()Returns the number of elements equal to the specified objectint
max()Returns the maximum element of a collection (according to natural ordering)T
min()Returns the minimum element of a collection (according to natural ordering)T
disjoint()Checks if two collections have no elements in commonboolean
copy()Copies all elements from one list into anothervoid
fill()Replaces all elements of the list with the specified objectvoid
replaceAll()Replaces all occurrences of one value with another in a listboolean
unmodifiableList()Returns an unmodifiable (read-only) view of the specified listList
unmodifiableSet()Returns an unmodifiable (read-only) view of the specified setSet
unmodifiableMap()Returns an unmodifiable (read-only) view of the specified mapMap

Previous

Java Iterator Interface

Next

Java System Methods