This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman 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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "change while loop to recursion?" Watch "change while loop to recursion?" New topic
Author

change while loop to recursion?

mike fusc
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 63227
    
  69

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
Bartender

Joined: Sep 20, 2010
Posts: 4000
    
  18

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.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3151
    
  33

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


Mohamed Sanaulla | My Blog
 
Have you checked out Aspose?
 
subject: change while loop to recursion?
 
It's not a secret anymore!