Utility Classes: Collections and Arrays


  • Both of these java.util classes provide
  • A sort() method. Sort using a Comparator or sort using natural order.
  • A binarySearch() method. Search a pre-sorted array or List.
  • Arrays.asList() creates a List from an array and links them together.
  • Collections.reverse() reverses the order of elements in a List.
  • Collections.reverseOrder() returns a Comparator that sorts in reverse.
  • Lists and Sets have a toArray() method to create arrays.