Code: Select all
binarySearch(T[] a, T key, Comparator<? super T> c)
you need the array or the list to be sorted first and you can use the Comparator
during sorting. So i don't understand the practical use of this method.
Another question is that in case of this question, if I pass anything other than String in binarysearch say
Code: Select all
Arrays.binarySearch(sa, 5)
doesn't compile if I pass other than the primitive type. I'm guessing it has something to do with strongly typed primitive arrays while String not being a data type.