How to sort an ArrayList?

后端 未结 20 2131
有刺的猬
有刺的猬 2020-11-22 06:19

I have a List of doubles in java and I want to sort ArrayList in descending order.

Input ArrayList is as below:

List testList = new Arr         


        
20条回答
  •  再見小時候
    2020-11-22 06:50

    Collections.sort(testList);
    Collections.reverse(testList);
    

    That will do what you want. Remember to import Collections though!

    Here is the documentation for Collections.

提交回复
热议问题