Sorting in Collection

  • String objects
  • Wrapper class objects
  • User-defined class objects
  • Collections class provides static methods for sorting the elements of collection.If collection elements are of Set type, we can use TreeSet.But We cannot sort the elements of List.Collections class provides methods for sorting the elements of List type elements.

    Method of Collections class for sorting List elements

    public void sort(List list): is used to sort the elements of List.List elements must be of Comparable type.


    Flash Soon

    Copyright ©2017 Design& development by HN