• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

binarySearch() : Help Needed

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic