top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can we sort a list of Objects in java?

0 votes
381 views
How can we sort a list of Objects in java?
posted Aug 29, 2017 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

If we need to sort an array of Objects, we can use Arrays.sort(). If we need to sort a list of objects, we can use Collections.sort(). Both these classes have overloaded sort() methods for natural sorting (using Comparable) or sorting based on criteria (using Comparator).
Collections internally uses Arrays sorting method, so both of them have same performance except that Collections take sometime to convert list to array.

answer Aug 30, 2017 by Pankaj Singh
...