Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2004
    Location
    USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question recursion in java

    how would i take
    Code:
    public String reversal(String x){
    int y = x.lenght();
    String s =""
    for(Int j=y-1;j>=0;j--)
      s+=x.charAt(j);
    return s;
    }
    and write a recursive function for it to do the same thing?

  • #2
    New Coder
    Join Date
    Mar 2005
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Before I help out on this one....please tell me you are not using this for real code. If your question is actually about recursion I'll be glad to help you out, if you are actually trying to append chars to a String like this(in reverse or normally) , I'll show you a MUCH better and more effecient way to do it.

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    USA
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    i am not using this for code. I just practiceing for the ap computer science AB exam in four weeks.


  •  

    Posting Permissions

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