Well, you never change searchValue inside the loop so if it's not the same as your loop counter you're entering an eternal loop.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Look at the do/while loop all by itself:
do {
optimalSearch.add(new Integer(nums[i]));
System.out.println("searchValue is " + searchValue);
}
while (i != searchValue);
This commands java to loop those two lines until search value != i. Well neither of those two lines up there is going to cause search value to change!! So it loops forever.
JeffHeaton
Junior Poster in Training
58 posts since Jul 2005
Reputation Points: 12
Solved Threads: 0
Think about what you want to do and how you'd do that if you were to do it with buckets full of marbles.
Write that down, then translate that into code.
Your entire algorithm is wrong, and your description of what you want to do is so vague it seems to me you don't even know yourself what you're trying to achieve here.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337