Collections Utility Class Flashcards Preview

OCP > Collections Utility Class > Flashcards

Flashcards in Collections Utility Class Deck (11):
1

Looks for the key in List. If found, returns a value >= 0; otherwise returns a negative value. It has an overloaded version that also takes a comparator object.

int binarySearch(List, key)

2

Copies all elements from src List to dst List.

void copy(dest, src)

3

Fills the whole List with the value obj.

void fill(List, obj)

4

Returns the max element in the list. Has an overloaded version that takes a comparator.

T max(Collection)

5

Returns the min element in the list. Has an overloaded version that takes a comparator.

T min(Collection)

6

Replaces all occurences of oldVal with newVal in the list.

boolean replaceAll(List, oldVal, newVal)

7

Reverses all the elements in the given list.

void reverse(List)

8

Rotates the list given by the value distance.

void rotate(List, int distance)

9

Shuffles the elements in the list randomly.

void shuffle(List)

10

Sorts the list in its natural order. Has an overloaded version that also takes a comparator object.

void sort(List)

11

Swaps the elements in the positions i and j in the list.

void swap(List, int i, int j)