its not running and i am confused where is the problem here.
Post by:Igor Ko
, Ranch Hand
It is not do while problem...
In such case to check some logical process, see it in debuger, or add printing (likes System.out.println("go to left...")) for each logical brach, and then you easy can see how it is working...
Post by:Jeff Pavlocak
Can you print out the value of tempNode before you enter the do loop? This way you can see if it really is a null and not a problem with the logic in your loop.
Post by:Emmy Rauch
You seem to have an misplaced bracket first of all, I don't see how this could compile like that. Assuming that bracket is removed, if the value is in the tree but not the node the code will return -1 every time because you have the return statement inside the do-while loop. If you fix these and still have a problem, post again. Btw, you should indent and use the code tags when you post
Post by:Ernest Friedman-Hill
I see various logical problems, but I'm not sure whether you're showing the whole method here, or whether part is cut off at the bottom, so I'm not exactly sure what to recommend.
It's hard to tell because of the lack of formatting, but there's an extra close bracket before the two lines
//current = null; return -1 * counter;
and that extra bracket is going to keep this code from compiling.
A good programmer's editor or IDE can help you to find this kind of problem as you type. There are several excellent free Java IDEs (Eclipse, NetBeans) and editors like Emacs that would let you know about mistakes like this as soon as it happened. it's worth the small investment in time to learn to use one of these tools.
Finally, note that I've already pointed you to our naming policy once, and asked you to go here and update your display name. Please do so now, before posting again, or I'll have to close your account.
This thread has been viewed 1295 times.
All times above are in ranch (not your local) time.
The current ranch time is Sep 26, 2018 04:21:56.