Using Sorting, we can sort element of -
The Collections in java provide the static method for sorting elements of it if an element is in Set type, you can use TreeSet but it can’t sort the element in List.it provides a method for sorting elements in List type.
public void sort(List list) /**Sort the elements of List. *List elements must be of the comparable type. */
The String classes & wrapper classes are used to implement a comparable interface if we store objects of string or wrapper class, it can be comparable.