如何在java中对数组列表进行冒泡排序?

发布于 2024-10-11 00:15:35 字数 69 浏览 0 评论 0原文

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

How to bubble sort a arraylist in java?
i want to bubble sort an arraylist. or is there a better way to sort an arraylist or list.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

年少掌心 2024-10-18 00:15:35

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

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

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

is there a better way to sort an arraylist or list.

Yes: use the sorting that is built into the standard library.

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

梦纸 2024-10-18 00:15:35

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

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

我想说的是,要对它进行排序

Collections.sort(list);

,这将对 ArrayList 进行排序

To sort an ArrayList I used the Collections.sort(), included the in the ArrayList class.
eg.

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

To sort it I would say,

Collections.sort(list);

and this would sort the ArrayList

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文