what if I don't want to sort the list?
If it is not sorted, the results are undefined. If the list contains multiple elements equal to the specified object, there is no guarantee which one will be found.
, , , binarySearch.
an anyone please tell me why should I use binary search instead of manually searching.
ArrayList, random access - , O (log n).
:
This method runs in log(n) time for a "random access" list (which provides near-constant-time positional access).
, , randon access ex. LinkedList, O(n)
If the specified list does not implement the RandomAccess interface and is large, this method
will do an iterator-based binary search that performs O(n) link traversals and O(log n) element
comparisons.