News

Sometimes we want to sort a list based on some property. suppose we have a list of usermodel and we want to sort list by firstname then we can do that easily by using collections.sort() and comparator ...
Do you need to know how to sort Java objects in a collection, array, or map? Here's how to use the Comparable and Comparator interfaces and avoid ClassCastExceptions.