Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem while finding/searching a tree node- Urgent help needed!

843805Dec 29 2005 — edited Dec 29 2005
Hello,

Can anyone help me with the code below. This code is used to search and return a node whose "nodeName" matches with the nodeName
entered by the user (the 2nd argument).
Although the code finds the node and returns it, the control again comes back to it because of recursion there by ultimately returning a different node.

"aqsWB.treeNode" is a class created by me.

public aqsWB.treeNode findNext(aqsWB.treeNode root, String nodeName) {
aqsWB.treeNode child = null;
for(int i=0; i<root.getChildCount(); i++) {
child = (aqsWB.treeNode)root.getChildAt(i);
if(child.isLeaf()) {
if(child.getNodeName().equalsIgnoreCase(nodeName)) {
break;
}
} else {
if(child.getNodeName().equalsIgnoreCase(nodeName)) {
break;
}
findNext(child, nodeName);
}
}
return child;
}


Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 26 2006
Added on Dec 29 2005
5 comments
56 views