This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes change while loop to recursion? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "change while loop to recursion?" Watch "change while loop to recursion?" New topic

change while loop to recursion?

mike fusc

Joined: Mar 07, 2010
Posts: 15

That is my code for a remove method that i created for a project and it works flawlessly, but I want to use recursion instead of the while loop. I just don't know where to start
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60810

mike fusc wrote:... it works flawlessly

Then why mess with it?

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 3605

I wouldn't worry about recursion. First, start giving all your variables (or at least your method signatures) meaningful names. cd, rmR and ptr simply won't do.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068

Why would you want to use recursion? Are recursions better than loops?

Mohamed Sanaulla | My Blog
I agree. Here's the link:
subject: change while loop to recursion?
Similar Threads
problem in parsing an XML using SAX parser.
Trying hard to make a basic String Class
Is this legal syntax ? A d = new A().aob = new A();
How to add a an object to a arraylist without overwriting other objects in the arraylist
tripleCut Solitaire Algorithim