Searching in an array with custom comparator in java

前端 未结 4 1736
醉酒成梦
醉酒成梦 2021-01-17 00:58

Why does it always return 49999 no matter what strToSearch variable holds? Even with the clank search variable it returns the same. Have I missed s

4条回答
  •  孤独总比滥情好
    2021-01-17 01:24

    You assume that String strToSearch is of type "12,12". To make this code work just change strToSearch

    For example:

    Arrays.binarySearch(arr, "12,12", new Comparator)
    

提交回复
热议问题