Collections vs Arrays regarding sort()

前端 未结 8 2073
北荒
北荒 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:46

    I know Arrays' sort() is using binary search for sort()

    No, you don't know any such thing. It doesn't do that. See the Javadoc.

    The statement doesn't even make sense. You can't 'use binary search for sort'. Binary search only worked when the data is already sorted. Maybe what you read is that Arrays.binarySearch() assumes the data is sorted.

提交回复
热议问题