This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in K&B SCJP 5: topic binarySearch() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt in K&B SCJP 5: topic binarySearch()" Watch "Doubt in K&B SCJP 5: topic binarySearch()" New topic
Author

Doubt in K&B SCJP 5: topic binarySearch()

Franz Fountain
Ranch Hand

Joined: Nov 15, 2006
Posts: 58
K&B p. 557 4th bullet
"which is passed as the second argument to the binarySearch() method."
s/b
"which is passed as the third argument to the binarySearch() method."

In other words the Comparator is the 3rd argument to binarySearch() not the 2nd. See example on same page at "#5".
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
Right Franz,
In binarySearch()method the first argument is for the array in which search to be made,the second is the key which is to be searched and third(optional) is for the comparator.


~Sanjeev Singh<br />SCJP 1.5
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Doubt in K&B SCJP 5: topic binarySearch()