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
Problem is in your binarysearch's comparator method. It should be re-written like this:
System.out.println(Arrays.binarySearch(arr, strToSearch, new Comparator() {
@Override
public int compare(String o1, String o2) {
if(o1 != null && o2 != null && !o1.isEmpty() && !o2.isEmpty() && o1.indexOf(",") != -1) {
String[] o1Arr = o1.split(",");
int i1 = Integer.parseInt(o2);
int i2 = Integer.parseInt(o1Arr[0]);
return i2-i1;
}
return 0;
}
}));