1.

How to sort elements of ArrayList?(a) Collection.sort(listObj);(b) Collections.sort(listObj);(c) listObj.sort();(d) Sorter.sortAsc(listObj);This question was addressed to me in an international level competition.My query is from Data Structures-List in chapter java.util – The Collections Framework of Java

Answer»

Right choice is (b) COLLECTIONS.sort(listObj);

To explain: Collections provides a METHOD to sort the LIST. The order of sorting can be DEFINED USING Comparator.



Discussion

No Comment Found

Related InterviewSolutions