Java-Recursion: When does statements after a recursive method call executes
Posted
by
Ruru Morlano
on Stack Overflow
See other posts from Stack Overflow
or by Ruru Morlano
Published on 2012-12-18T04:34:10Z
Indexed on
2012/12/18
5:03 UTC
Read the original article
Hit count: 184
When are statements after the method call itself going to execute?
private void inorderHelper(TreeNode node)
{
if ( node==null )
return;
inorderHelper(node.leftNode);
System.out.printf("%d", node.data);
inorderHelper(node.rigthNode);
}
All I can see is that the line of codes inorderHelper(node.leftNode) will continue to iterate until node == null and the method terminates immediately before node.data is printed. I think that I didn't get well recursion but all examples I can find doesn't have statements after the recursive call. All I want to know is when are statements like System.out.printf("%d",node.data) going to execute before the method return?
© Stack Overflow or respective owner