This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Qa dd'rouy Again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Qa dd Watch "Qa dd New topic

Qa dd'rouy Again

Umair Uddin

Joined: Sep 12, 2001
Posts: 14
please give me the simplest example of Recursion ... with basic definition of process(recursion) i am so confused about it .....
Waiting for response
Umair Uddin Qa dd'rouy
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

A recursive method is simply one that calls itself. The simplest kind of recursion goes like this:

That's basically an infinite loop, although it leads to a side effect known as being "out of memory." You'll run out of memory because each time recurse() is called, the currently calling method has to be stored while it waits for the now-called recurse() to do its thing. Since there's no reason for recurse() to ever quit calling itself, it's just a matter of time before you blow up.
To avoid this, a recursive method specifies a condition that allows each called method to return to its calling method, until they're all resolved. For example:

This can be a bit of a mind-bender if you don't know how a process tracks the instructions that it runs, so just let it soak for a while.
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
greg philpott
Ranch Hand

Joined: Nov 10, 2000
Posts: 73
here is another example that shows how it can be usefull:
Consider Paul's rocket mass heater.
subject: Qa dd'rouy Again
It's not a secret anymore!