0

如何在java中对arraylist进行冒泡排序?
我想对数组列表进行冒泡排序。还是有更好的方法来对数组列表或列表进行排序。

4

2 回答 2

2

有没有更好的方法来对数组列表或列表进行排序。

是的:使用标准库中内置的排序。

例如,http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html#sort%28java.util.List%29

于 2011-01-07T08:28:44.343 回答
0

为了对 ArrayList 进行排序,我使用了 Collections.sort(),它包含在 ArrayList 类中。例如。

 ArrayList<String> list = new ArrayList<String>();

为了排序,我会说,

Collections.sort(list);

这将对ArrayList

于 2020-10-14T22:45:11.467 回答