Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Franz Fountain
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic