Arrays Utility Class Flashcards

1
Q

Creates a fixed-size List out of the given array.

A

List asList(T…a)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Searches for a key in the array. Returns an int value >= the index of the key if found. Otherwise returns a negative value. Overloads available for primitive types like int[] and byte[] and for a comparator object.

A

int binarySearch(objArray, key)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Checks if the contents of array1 and array2 are equal. Overloads available for primitive types.

A

boolean equals(array1, array2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fills the array with the value val. Overloads available for primitive types.

A

void fill(Array, val)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Sorts the array based on natural order. Overloads available for primitives and a comparator object.

A

void sort(array)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Returns the String representation of the given array.

A

String toString(array)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly