I have a list of more than 37K items, and I already implemented hashCode(), equals(), so I wonder Collections.binarySearch() can help improve the performance and faster than indexOf() method.
I have a list of more than 37K items, and I already implemented hashCode()
Share
If your collection is sorted,
binarySearch()will be O(log n) as opposed toindexOf()‘s O(n) and you will definitely see an improvement.