Hi there, i have a problem when trying to search a particular node whilst using a keyword.... The result is always to null and im suspecting that im not actually pointing to the object in the node but just the position. Would appreciate any suggestions please. Attaching code and sry if there;s quite a bit there......
I suspect one problem is that your search function tests for equality between two strings using the "==" operator; in order to see if two different strings have the same value, use string1.equals(string2), or string1.equalsIgnoreCase(string2)
There are other possible problems with your code, but I would definitely change that.
I would also suggest that you learn to use a debugger; you can set a "breakpoint" at a line, meaning that execution stops at that line and allows you to view the values of variables. Experience will suggest where to set breakpoints to speed up the debugging process, in the meanwhile you'll get some insight into what's really happening. In this case, once you had stepped through the line temp.obj.Surname == keyword and seen that the values were the same but it didn't match in that test, then your question would become very specific: Why doesn't temp.obj.Surname == keyword return true? The more specific questions are easier to answer, and you will be able to answer more of them yourself as you do more programming.
Joined: Mar 30, 2011
Thanks Ralph for the time taken to review my code. You were right regarding the equality operator and i used the one suggested by yourself string1.equals(string2) and i got a good result.
Will def search about using breakpoints aswell, didnt actually know about them.