How can I sort an ArrayList of Strings in Java?

后端 未结 5 1099
遥遥无期
遥遥无期 2020-11-30 09:21

I have Strings that are put into an ArrayList randomly.

private ArrayList teamsName = new ArrayList();
         


        
5条回答
  •  遥遥无期
    2020-11-30 10:25

    Take a look at the Collections.sort(List list).

    You can simply remove the first element, sort the list and then add it back again.

提交回复
热议问题