Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By wsaryada

Thread: Counting the length of a string recursively

  1. #1
    Zoralink23 is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Counting the length of a string recursively

    I'd appreciate any help with this, I've been working on a series of recursive problems all night and am pretty sure my brain has melted at this point, because I'm not even registering what I've typed any more. Recursion breaks my brain.

    Java Code:
    	public static int Six(String s) {
    			return 0; 
    			return 1 + Six(s);
    Unfortunately this results in an overflow and I'm not entirely sure why. Any help? Thanks in advance!

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Bali, Indonesia
    Rep Power

    Default Re: Counting the length of a string recursively

    I believe you program will run a never ending loop. As the string that calling back to the Six() method is never changed. I will only stop when the JVM is run out of memory.
    quad64bit likes this.

Similar Threads

  1. Recursively searching a string
    By fam2315 in forum New To Java
    Replies: 0
    Last Post: 10-13-2012, 06:25 PM
  2. Replies: 11
    Last Post: 08-15-2011, 10:12 AM
  3. String.length?
    By rizowski in forum New To Java
    Replies: 7
    Last Post: 11-20-2010, 05:33 PM
  4. string length HELP PLZ!!
    By vette427 in forum Eclipse
    Replies: 1
    Last Post: 09-23-2010, 06:12 AM
  5. Replies: 8
    Last Post: 11-20-2009, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts