Hi all,
I'd like to print the tree:
A-
|- B
|- C
D-
|- E
|- F
|- G
like:
A
\tB
\tC
D
\tE
\t\tF
\tG
The problem is that every time I call the recursion it does not print an extra tab to the lower level.
here is my code:
private void printTree(MyTreeNode node) {
System.out.println(node.getName());
if(node.getChildren() != null && node.getChildren().length != 0){
for(MyTreeNode n : node.getChildren()){
System.out.print("\t");
printTree(n);
}
}
}