Collections vs Arrays regarding sort()

前端 未结 8 2003
北荒
北荒 2021-01-31 03:20

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 Co

8条回答
  •  遥遥无期
    2021-01-31 03:45

    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.

    Also, for what it's worth, notice that Arrays.sort runs a merge sort.

提交回复
热议问题