To work with binarySearch (), your list must be sorted. equals () and hashCode () have nothing to do with sorting. your objects must be comparable, or you must have an appropriate comparator. in any case, you must first sort the list.
and yes, provided the list is sorted, then you are likely to get better performance from binarySearch () compared to indexOf ().
jtahlborn
source share