File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Recursion FindPath[solved] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Recursion FindPath[solved]" Watch "Recursion FindPath[solved]" New topic
Author

Recursion FindPath[solved]

David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Solved, thank you!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Hard to say what's happening without seeing the canFlowOffMap method.


Ping & DNS - updated with new look and Ping home screen widget
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Sorry,

Actually it was meant to be canFindPath (I changed name). I'm making recursive calls to itself.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
If any of the recursive calls ever return "true", then you should not recurse any further, but return straight back up the call stack. As it is, you're ignoring the returned value, and continue to look for solutions in other directions.
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Thank you for replying. So then I need to put if statements inside my check N/W/S/E loops to check if the program returned true?? That's what I was thinking of earlier this morning but wasn't sure. Should I use a local variable to keep track of the boolean?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
The easiest may be to replace "canFindPath(...)" by "if (canFindPath(...)) return true" or something like that.
David Delgado
Greenhorn

Joined: Sep 19, 2010
Posts: 6
Thank you Uff, that solved my problem.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Don't go and edit your first post

Now people who read this thread can't understand what the question was about, and the replies all read as nonsense.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

I'd go further and ask you not to edit any post that has been replied to, because of the same reason.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Indeed, I feel like I helped someone who was not supposed to ask for help with his homework.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recursion FindPath[solved]
 
Similar Threads
datasource look up problem
geting only l;ast vale from hashmap
Creating exe in java...
Where I have to mention my template in XML?
JInternalFrame with glass pane