This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The array is sorted, don't use a linear search (a for loop) - perform a binary search. There is possibly something in the J2SE API spec. for doing this, but if not, it's not too difficult to throw together.
If this is homework, it is likely that a binary search is what your teacher might be expecting.
Originally posted by Matt Hall: The code is still only outputting an array of zeroes, whereas I want 1 value back from the array, not the array itself.
It is your program, you have to debug it. From looking at your other posts, I am not even sure if you completely understand the algorithm you are trying to implement.
Look at the loop. How is the algorithm supposed to work? What is actually happening? And what are the differences? Once you understand what is unexpected, you can either add debugging messages to look at what is wrong. Or make a small change. Repeat as necessary.
Try it for a few iterations... It is not as scary as it sounds.
Joined: Oct 17, 2005
Take a look at what your doing, can you see why your printing out the whole array instead of one value?