我被递归搜索困住了,我正在使用 gwt,基本上我想在 gwt 树中搜索一个节点,这是我的代码。提前谢谢。我不擅长递归:-(
public TreeItem search2(String sName, TreeItem node){
TreeItem treeItem=null;
String sValue ="";
boolean bFound=false;
System.out.println("Father Node:" + node.getText() + " child nodes:" + node.getChildCount());
for (int i=0;i<node.getChildCount();i++){
treeItem = node.getChild(i);
sValue = treeItem.getText();
System.out.println("searching...."+sValue);
if (sValue.equalsIgnoreCase(sName)){
bFound=true;
System.out.println("!!found!!!!"+sName + " node to return:" + treeItem.getText());
return treeItem;
}
else {
return search2(sName,treeItem);
}
}
return treeItem;
}