METHODS - Array
5 flashcards · Other · by Steven Bui
Arrays.sort(array)
O(n log n) Uses the quick sort algorithm to sort arrays of primitive types (int, char) RETURN: void - the given array is sorted
Arrays.binarySearch(array, element)
O(log n) Binary search is an O(log n) algorithm. RETURN: int - index of the element
Arrays.equals(array, array)
O(n) Iterates through the length of both arrays. RETURN: boolean - if the arrays are equal
Arrays.copyOf(array, new_length)
O(n) Iterates through the length of the array to the given length. RETURN: array[] - copy of the array
array.length
O(1) The length is a field. RETURN int - length of the array