• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
little off topic, need help understand a recursive call
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

little off topic, need help understand a recursive call


  • Subject: little off topic, need help understand a recursive call
  • From: Theodore Petrosky <email@hidden>
  • Date: Wed, 12 Nov 2014 06:32:03 -0500

I am trying like mad to learn more. So I have decided to put time into Recursive algorithms. I do not want to start a conversation whether or not one should or should not use recursion in this example. That is a conversation for another day. I don’t believe that using it here will impact the app at all.

As an experiment I am trying to use one in my validation method. Would one of you great minds take a look at this. It works, but I feel I am jumping through too many hoops. This is my first attempt so have a little pity:


	public String validateHeight(String value) throws ValidationException {
		value = value.trim();

		if (!isNumber(value)) {
			throw new ValidationException("There can be only numbers in the Height field! (value was " + value +")");
		}
		return value;
	}

	private boolean isNumber(String stringToCheck) {
		if (stringToCheck.length() == 0) return true;
		if (!Character.isDigit(stringToCheck.charAt(0))) return false;
		return isNumber(stringToCheck.substring(1, stringToCheck.length()));
	}


My desire is to get better at this and learning recursion is very important. Also, when I look at other people’s code, there are times that there are recursive calls and I struggle to understand them.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: little off topic, need help understand a recursive call
      • From: Ramsey Gurley <email@hidden>
  • Prev by Date: Re: Version/build numbers?
  • Next by Date: My d2w edit page fields are disabled
  • Previous by thread: Re: Version/build numbers?
  • Next by thread: Re: little off topic, need help understand a recursive call
  • Index(es):
    • Date
    • Thread