Tag: comparator

Comparator List Sorting

Comparator List Sorting In this example showing how to sort objects in the List by using a comparator. Primitive Type List, Wrapper Classes Type List can be sorted by using the Collection.sort(), but Object type List can’t be sorted. To achieve this we can use either Comparator and Comparable.   Comparator A Comparator interface is […]

Arrays

Arrays Class This Class Present in java.util package. It defines several utility methods applicable for arrays. Sorting the elements of Arrays:-Arrays class defines the following three methods to perform sorting. Public static void sort(Primitive[] p) to sort the elements of primitive array, according to natural sorting order. Public static void sort(Object[] o) to sort the […]