#
Utility Methods (java.util)#
1. Sorting- Arrays.sort() - returns sorted arrays (arr), by quicksort methods,uses java.util.Arrays lib
- To sort Sub Array in range of start and end
- To sort array in Decending (Reverse) order using Collections.reverseOrder(); as argument
- To sort Sub Array in range of start and end
- Collection.sort() - sorting of lists like ArrayList, LinkedList, etc. , uses java.util.Collections lib
- To sortlist in Decending (Reverse) order using Collections.reverseOrder(); as argument
- To sortlist in Decending (Reverse) order using Collections.reverseOrder(); as argument
#
2. Searching- Arrays.binarySearch() - returns the position, searching a key value in Array using Binary Search
- Collections.binarySearch() - returns the position, searching a key value in list using Binary Search
#
3. Copying- Arrays.copyOf() - copy the contents of array to a new array with legth newLength
#
4. Rotate- Collection.rotate() - Rotate the list by distance, the element present at (i) will rotate to (i-distance)% list.size();
#
4. Frequency- Collection.frequency() - returns frequency of Object (o) in the list
#
5. Get Max- Collection.max() - returns maximum of all elements in the list