This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Recursion inside while loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Recursion inside while loop" Watch "Recursion inside while loop" New topic
Author

Recursion inside while loop

B M Tejaswi
Greenhorn

Joined: Jul 02, 2012
Posts: 11
Am trying to write a method that fetches records from DB and prepares a tree. I have uniqueID and parentID fields in records. Am trying to find a parent from the already built tree to insert new records using recursion. But my tree only builds upto level 2. After that it fails to return proper parent nodes. Below is my code
//Code calling the recursive code :


In recursive method i have to return the previous parent node to continue iteration of while loop. But am not able to figure out what i should return. Please help asap.
 
jQuery in Action, 2nd edition
 
subject: Recursion inside while loop
 
Similar Threads
Reading Elements from an ArrayList, 3 at a time
Exception: Servlet.service() for servlet jsp threw exception
do while help
recursion backwards?
Using Iterator with LinkedList