Sorting in CollectionWe can sort the elements of:
Method of Collections class for sorting List elementspublic void sort(List list): is used to sort the elements of List. List elements must be of the Comparable type. Note: String class and Wrapper classes implement the Comparable interface. So if you store the objects of string or wrapper classes, it will be Comparable.Example to sort string objectsTest it NowMukesh Saurav Tahir Viru Example to sort string objects in reverse orderViru Tahir Saurav Mukesh Example to sort Wrapper class objects101 201 230 Example to sort user-defined class objectsMukesh Saurav Tahir Viru |