aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes binarySearch() : Help Needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "binarySearch() : Help Needed" Watch "binarySearch() : Help Needed" New topic
Author

binarySearch() : Help Needed

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
At page 557 :

If the collection/array you want to search was sorted using a Comparator, it must be searched using the same Comparator, which is passed as the second argument to the binarySearch() method. Remember that Comparators cannot be used when searching arrays of primitives.

Is comparator 2nd or 3rd argument to binarySearch() ?
Allan Jacobs
Greenhorn

Joined: Aug 28, 2006
Posts: 15
Third argument.

Simple API questions are answerable using the Javadoc for the Java API at
http://java.sun.com/j2se/1.5.0/docs/api/. The signature for the binarySearch
that takes a comparator is:

static <T> int binarySearch(T[] a, T key, Comparator<? super T> c)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: binarySearch() : Help Needed
 
Similar Threads
Doubt in K&B SCJP 5: topic binarySearch()
Collections.binarySearch(...)
BinarySearch
binarySearch() method of Arrays
Java Comparators