关于sort()的集合与数组 [英] Collections vs Arrays regarding sort()
问题描述
关于sort()的集合与数组
这两个关于sort()方法的区别是什么?我知道Arrays的sort()正在使用二进制搜索sort(),那么Collections呢?以及如何选择使用哪个?
谢谢!
Collections vs Arrays regarding sort() What is the difference between these two regarding sort() method? I know Arrays' sort() is using binary search for sort(), what about Collections'? And how to choose which to use? Thanks!
推荐答案
好吧,除了操作不同的东西( Collections.sort
在 List
上运行, Arrays.sort
在数组上运行), java.util.Collections.sort()
只需调用 java.util.Arrays.sort()
来做繁重的工作。
Well, besides operating on different stuff (Collections.sort
operates on a List
, and Arrays.sort
operates on an array), java.util.Collections.sort()
simply calls java.util.Arrays.sort()
to do the heavy lifting.
另外,为了它的价值,注意 Arrays.sort
运行合并排序。
Also, for what it's worth, notice that Arrays.sort
runs a merge sort.
这篇关于关于sort()的集合与数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!