[Logo]
Forums Register Login
Master exam question
Given a properly prepared String array containing five elements,which range
of results could a proper invocation of Arrays.binarySearch() produce?

Ans. -6 through 4

Why is the answer -6.According to me the last insertion point shoule be -5 by the formula
-(insertion point )- 1.
Since the last index must be 4 it becomes -4-1=-5

Correct me if i m wrong
This question has been asked earlier in the forum too. Like here. Search through the forum for previous discussions of this question...
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss


This thread has been viewed 1188 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jul 16, 2018 12:15:04.